Update vendor directory
This commit is contained in:
35
vendor/github.com/jessevdk/go-flags/help.go
generated
vendored
35
vendor/github.com/jessevdk/go-flags/help.go
generated
vendored
@@ -72,6 +72,9 @@ func (p *Parser) getAlignmentInfo() alignmentInfo {
|
||||
var prevcmd *Command
|
||||
|
||||
p.eachActiveGroup(func(c *Command, grp *Group) {
|
||||
if !grp.showInHelp() {
|
||||
return
|
||||
}
|
||||
if c != prevcmd {
|
||||
for _, arg := range c.args {
|
||||
ret.updateLen(arg.Name, c != p.Command)
|
||||
@@ -79,7 +82,7 @@ func (p *Parser) getAlignmentInfo() alignmentInfo {
|
||||
}
|
||||
|
||||
for _, info := range grp.options {
|
||||
if !info.canCli() {
|
||||
if !info.showInHelp() {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -225,12 +228,12 @@ func (p *Parser) writeHelpOption(writer *bufio.Writer, option *Option, info alig
|
||||
}
|
||||
|
||||
var envDef string
|
||||
if option.EnvDefaultKey != "" {
|
||||
if option.EnvKeyWithNamespace() != "" {
|
||||
var envPrintable string
|
||||
if runtime.GOOS == "windows" {
|
||||
envPrintable = "%" + option.EnvDefaultKey + "%"
|
||||
envPrintable = "%" + option.EnvKeyWithNamespace() + "%"
|
||||
} else {
|
||||
envPrintable = "$" + option.EnvDefaultKey
|
||||
envPrintable = "$" + option.EnvKeyWithNamespace()
|
||||
}
|
||||
envDef = fmt.Sprintf(" [%s]", envPrintable)
|
||||
}
|
||||
@@ -305,7 +308,7 @@ func (p *Parser) WriteHelp(writer io.Writer) {
|
||||
}
|
||||
} else if us, ok := allcmd.data.(Usage); ok {
|
||||
usage = us.Usage()
|
||||
} else if allcmd.hasCliOptions() {
|
||||
} else if allcmd.hasHelpOptions() {
|
||||
usage = fmt.Sprintf("[%s-OPTIONS]", allcmd.Name)
|
||||
}
|
||||
|
||||
@@ -393,7 +396,7 @@ func (p *Parser) WriteHelp(writer io.Writer) {
|
||||
}
|
||||
|
||||
for _, info := range grp.options {
|
||||
if !info.canCli() || info.Hidden {
|
||||
if !info.showInHelp() {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -489,3 +492,23 @@ func (p *Parser) WriteHelp(writer io.Writer) {
|
||||
|
||||
wr.Flush()
|
||||
}
|
||||
|
||||
// WroteHelp is a helper to test the error from ParseArgs() to
|
||||
// determine if the help message was written. It is safe to
|
||||
// call without first checking that error is nil.
|
||||
func WroteHelp(err error) bool {
|
||||
if err == nil { // No error
|
||||
return false
|
||||
}
|
||||
|
||||
flagError, ok := err.(*Error)
|
||||
if !ok { // Not a go-flag error
|
||||
return false
|
||||
}
|
||||
|
||||
if flagError.Type != ErrHelp { // Did not print the help message
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user