command: backport patch for mitchellh/cli help flag handling (#3536)

This patch backports a fix which will show the correct usage screen for
command line flags.

This is considered a temporary fix until the code has been refactored.
Newer versions of the cli library require that the flag set is populated
when Help() is called or that it is populated within Help() itself.

Fixes #3536
pull/3543/head
Frank Schroeder 2017-10-05 17:19:25 +02:00 committed by Frank Schröder
parent ce0d03c46a
commit 59b84fcda3
1 changed files with 6 additions and 6 deletions

View File

@ -578,12 +578,6 @@ func (c *CLI) processArgs() {
break
}
// Check for help flags.
if arg == "-h" || arg == "-help" || arg == "--help" {
c.isHelp = true
continue
}
// Check for autocomplete flags
if c.Autocomplete {
if arg == "-"+c.AutocompleteInstall || arg == "--"+c.AutocompleteInstall {
@ -604,6 +598,12 @@ func (c *CLI) processArgs() {
continue
}
// Check for help flags.
if arg == "-h" || arg == "-help" || arg == "--help" {
c.isHelp = true
continue
}
if arg != "" && arg[0] == '-' {
// Record the arg...
c.topFlags = append(c.topFlags, arg)