diff options
author | Ville Skyttä <[email protected]> | 2024-04-07 20:33:17 +0000 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-04-11 15:34:26 +0200 |
commit | a67650b6f764d201fde22b1bc3c06b923fdc5438 (patch) | |
tree | 698bdb49baf78317ad506fcf8642a0f6da883543 /commands/env.go | |
parent | 2a060b37a32c3831ece2203b8b5451adb3c787af (diff) | |
download | hugo-a67650b6f764d201fde22b1bc3c06b923fdc5438.tar.gz hugo-a67650b6f764d201fde22b1bc3c06b923fdc5438.zip |
completion: Improve existing argument completions, add many more
Do not offer filenames to arguments not taking one, complete arguments
of options taking resource kinds, directory names, --logLevel, release
--step, config and new --format.
As an internal refactoring, use higher level functions to set flag
completions. SetAnnotation works, but is more verbose than
alternatives, and uses bash specific wording.
While at it, move setting completions next to flag definitions
consistently.
Remove superfluous --destination completer setting, which is already
set elsewhere.
Diffstat (limited to 'commands/env.go')
-rw-r--r-- | commands/env.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/commands/env.go b/commands/env.go index 8e4f03c55..843fc49d1 100644 --- a/commands/env.go +++ b/commands/env.go @@ -19,6 +19,7 @@ import ( "github.com/bep/simplecobra" "github.com/gohugoio/hugo/common/hugo" + "github.com/spf13/cobra" ) func newEnvCommand() simplecobra.Commander { @@ -47,6 +48,9 @@ func newEnvCommand() simplecobra.Commander { } return nil }, + withc: func(cmd *cobra.Command, r *rootCommand) { + cmd.ValidArgsFunction = cobra.NoFileCompletions + }, } } @@ -59,5 +63,8 @@ func newVersionCmd() simplecobra.Commander { }, short: "Print Hugo version and environment info", long: "Print Hugo version and environment info. This is useful in Hugo bug reports.", + withc: func(cmd *cobra.Command, r *rootCommand) { + cmd.ValidArgsFunction = cobra.NoFileCompletions + }, } } |