mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
Merge pull request #2928 from hashicorp/b-cli-autocomplete
Fix autocmpleting global flags
This commit is contained in:
3
vendor/github.com/mitchellh/cli/README.md
generated
vendored
3
vendor/github.com/mitchellh/cli/README.md
generated
vendored
@@ -18,6 +18,9 @@ cli is the library that powers the CLI for
|
||||
* Optional support for default subcommands so `cli` does something
|
||||
other than error.
|
||||
|
||||
* Support for shell autocompletion of subcommands, flags, and arguments
|
||||
with callbacks in Go. You don't need to write any shell code.
|
||||
|
||||
* Automatic help generation for listing subcommands
|
||||
|
||||
* Automatic help flag recognition of `-h`, `--help`, etc.
|
||||
|
||||
13
vendor/github.com/mitchellh/cli/cli.go
generated
vendored
13
vendor/github.com/mitchellh/cli/cli.go
generated
vendored
@@ -153,6 +153,14 @@ func (c *CLI) IsVersion() bool {
|
||||
func (c *CLI) Run() (int, error) {
|
||||
c.once.Do(c.init)
|
||||
|
||||
// If this is a autocompletion request, satisfy it. This must be called
|
||||
// first before anything else since its possible to be autocompleting
|
||||
// -help or -version or other flags and we want to show completions
|
||||
// and not actually write the help or version.
|
||||
if c.Autocomplete && c.autocomplete.Complete() {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// Just show the version and exit if instructed.
|
||||
if c.IsVersion() && c.Version != "" {
|
||||
c.HelpWriter.Write([]byte(c.Version + "\n"))
|
||||
@@ -197,11 +205,6 @@ func (c *CLI) Run() (int, error) {
|
||||
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// If this is a autocompletion request, satisfy it
|
||||
if c.autocomplete.Complete() {
|
||||
return 0, nil
|
||||
}
|
||||
}
|
||||
|
||||
// Attempt to get the factory function for creating the command
|
||||
|
||||
Reference in New Issue
Block a user