considering stderr in UsageString
This commit is contained in:
11
command.go
11
command.go
@ -384,13 +384,22 @@ func (c *Command) Help() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// UsageString return usage string.
|
||||
// UsageString returns usage string.
|
||||
func (c *Command) UsageString() string {
|
||||
// Storing normal writers
|
||||
tmpOutput := c.outWriter
|
||||
tmpErr := c.errWriter
|
||||
|
||||
bb := new(bytes.Buffer)
|
||||
c.outWriter = bb
|
||||
c.errWriter = bb
|
||||
|
||||
c.Usage()
|
||||
|
||||
// Setting things back to normal
|
||||
c.outWriter = tmpOutput
|
||||
c.errWriter = tmpErr
|
||||
|
||||
return bb.String()
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user