Skip to content

Commit

Permalink
lxc: Add dynamic --project completions to all commands
Browse files Browse the repository at this point in the history
Signed-off-by: Kadin Sayani <[email protected]>
  • Loading branch information
kadinsayani committed Jan 7, 2025
1 parent 72baca0 commit 0ac1a3d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lxc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ For help with any of those, simply call them with --help.`))
app.PersistentFlags().BoolVarP(&globalCmd.flagQuiet, "quiet", "q", false, i18n.G("Don't show progress information"))
app.PersistentFlags().BoolVar(&globalCmd.flagSubCmds, "sub-commands", false, i18n.G("Use with help or --help to view sub-commands"))

_ = app.RegisterFlagCompletionFunc("project", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
projects, directives := globalCmd.cmpProjects(toComplete)
if projects != nil {
return projects, directives
}

return nil, cobra.ShellCompDirectiveError
})

// Wrappers
app.PersistentPreRunE = globalCmd.PreRun
app.PersistentPostRunE = globalCmd.PostRun
Expand Down

0 comments on commit 0ac1a3d

Please sign in to comment.