MCPcopy Create free account
hub / github.com/dropbox/dbxcli / newCompletionCmd

Function newCompletionCmd

cmd/completion.go:23–99  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21)
22
23func newCompletionCmd() *cobra.Command {
24 noDesc := false
25 programName := RootCmd.Name()
26
27 completionCmd := &cobra.Command{
28 Use: "completion [bash|zsh|fish|powershell]",
29 Short: "Generate the autocompletion script for the specified shell",
30 Long: completionLong(programName),
31 Args: cobra.NoArgs,
32 ValidArgsFunction: cobra.NoFileCompletions,
33 RunE: func(cmd *cobra.Command, args []string) error {
34 return cmd.Help()
35 },
36 }
37
38 addCompletionNoDescFlag := func(cmd *cobra.Command) {
39 cmd.Flags().BoolVar(&noDesc, "no-descriptions", false, "disable completion descriptions")
40 }
41
42 bash := &cobra.Command{
43 Use: "bash",
44 Short: "Generate the autocompletion script for bash",
45 Long: bashCompletionLong(programName),
46 Args: cobra.NoArgs,
47 DisableFlagsInUseLine: true,
48 ValidArgsFunction: cobra.NoFileCompletions,
49 RunE: func(cmd *cobra.Command, args []string) error {
50 return cmd.Root().GenBashCompletionV2(cmd.Root().OutOrStdout(), !noDesc)
51 },
52 }
53 addCompletionNoDescFlag(bash)
54
55 zsh := &cobra.Command{
56 Use: "zsh",
57 Short: "Generate the autocompletion script for zsh",
58 Long: zshCompletionLong(programName),
59 Args: cobra.NoArgs,
60 ValidArgsFunction: cobra.NoFileCompletions,
61 RunE: func(cmd *cobra.Command, args []string) error {
62 if noDesc {
63 return cmd.Root().GenZshCompletionNoDesc(cmd.Root().OutOrStdout())
64 }
65 return cmd.Root().GenZshCompletion(cmd.Root().OutOrStdout())
66 },
67 }
68 addCompletionNoDescFlag(zsh)
69
70 fish := &cobra.Command{
71 Use: "fish",
72 Short: "Generate the autocompletion script for fish",
73 Long: fishCompletionLong(programName),
74 Args: cobra.NoArgs,
75 ValidArgsFunction: cobra.NoFileCompletions,
76 RunE: func(cmd *cobra.Command, args []string) error {
77 return cmd.Root().GenFishCompletion(cmd.Root().OutOrStdout(), !noDesc)
78 },
79 }
80 addCompletionNoDescFlag(fish)

Calls 5

completionLongFunction · 0.85
bashCompletionLongFunction · 0.85
zshCompletionLongFunction · 0.85
fishCompletionLongFunction · 0.85
powershellCompletionLongFunction · 0.85