Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/cmd/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var completionCmd = &cobra.Command{
Hidden: true,
DisableFlagsInUseLine: true,
ValidArgs: []string{"bash", "fish", "zsh"},
Args: cobra.ExactValidArgs(1),
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
RunE: completion,
}

Expand Down Expand Up @@ -194,7 +194,3 @@ func completionImageNamesFiltered(_ *cobra.Command, args []string, _ string) ([]

return imageNames, cobra.ShellCompDirectiveNoFileComp
}

func completionLogLevels(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
return []string{"trace", "debug", "info", "warn", "error", "fatal", "panic"}, cobra.ShellCompDirectiveNoFileComp
}
4 changes: 3 additions & 1 deletion src/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ func init() {

persistentFlags.CountVarP(&rootFlags.verbose, "verbose", "v", "Set log-level to 'debug'")

if err := rootCmd.RegisterFlagCompletionFunc("log-level", completionLogLevels); err != nil {
logLevels := []string{"trace", "debug", "info", "warn", "error", "fatal", "panic"}
completionFn := cobra.FixedCompletions(logLevels, cobra.ShellCompDirectiveNoFileComp)
if err := rootCmd.RegisterFlagCompletionFunc("log-level", completionFn); err != nil {
panicMsg := fmt.Sprintf("failed to register flag completion function: %v", err)
panic(panicMsg)
}
Expand Down
4 changes: 2 additions & 2 deletions src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/godbus/dbus/v5 v5.0.6
github.com/google/renameio/v2 v2.0.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.3.0
github.com/spf13/cobra v1.6.1
github.com/spf13/viper v1.20.1
github.com/stretchr/testify v1.10.0
golang.org/x/sys v0.29.0
Expand All @@ -28,7 +28,7 @@ require (
github.com/fatih/color v1.14.1 // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/opencontainers/runtime-spec v1.2.1 // indirect
Expand Down
Loading
Loading