mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-08 07:37:01 +02:00
Delegate usage to the UI
This commit is contained in:
parent
30dc835b2c
commit
eb4ab6840d
@ -313,17 +313,10 @@ type FlagSets struct {
|
|||||||
// NewFlagSets creates a new flag sets.
|
// NewFlagSets creates a new flag sets.
|
||||||
func NewFlagSets(ui cli.Ui) *FlagSets {
|
func NewFlagSets(ui cli.Ui) *FlagSets {
|
||||||
mainSet := flag.NewFlagSet("", flag.ContinueOnError)
|
mainSet := flag.NewFlagSet("", flag.ContinueOnError)
|
||||||
mainSet.Usage = func() {}
|
|
||||||
|
|
||||||
// Pull errors from the flagset into the ui's error
|
// Errors and usage are controlled by the CLI.
|
||||||
errR, errW := io.Pipe()
|
mainSet.Usage = func() {}
|
||||||
errScanner := bufio.NewScanner(errR)
|
mainSet.SetOutput(ioutil.Discard)
|
||||||
go func() {
|
|
||||||
for errScanner.Scan() {
|
|
||||||
ui.Error(errScanner.Text())
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
mainSet.SetOutput(errW)
|
|
||||||
|
|
||||||
return &FlagSets{
|
return &FlagSets{
|
||||||
flagSets: make([]*FlagSet, 0, 6),
|
flagSets: make([]*FlagSet, 0, 6),
|
||||||
|
Loading…
Reference in New Issue
Block a user