MCPcopy
hub / github.com/dgraph-io/dgraph / shellCompletionCmd

Function shellCompletionCmd

dgraph/cmd/root.go:207–257  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

205}
206
207func shellCompletionCmd() *cobra.Command {
208
209 cmd := &cobra.Command{
210
211 Use: "completion",
212 Short: "Generates shell completion scripts for bash or zsh",
213 Annotations: map[string]string{"group": "tool"},
214 }
215 cmd.SetHelpTemplate(x.NonRootTemplate)
216
217 // bash subcommand
218 cmd.AddCommand(&cobra.Command{
219 Use: "bash",
220 Short: "bash shell completion",
221 Long: `To load bash completion run:
222dgraph completion bash > dgraph-completion.sh
223
224To configure your bash shell to load completions for each session,
225add to your bashrc:
226
227# ~/.bashrc or ~/.profile
228. path/to/dgraph-completion.sh
229`,
230 Args: cobra.NoArgs,
231 RunE: func(cmd *cobra.Command, args []string) error {
232 return RootCmd.GenBashCompletion(os.Stdout)
233 },
234 })
235
236 // zsh subcommand
237 cmd.AddCommand(&cobra.Command{
238 Use: "zsh",
239 Short: "zsh shell completion",
240 Long: `To generate zsh completion run:
241dgraph completion zsh > _dgraph
242
243Then install the completion file somewhere in your $fpath or
244$_compdir paths. You must enable the compinit and compinstall plugins.
245
246For more information, see the official Zsh docs:
247http://zsh.sourceforge.net/Doc/Release/Completion-System.html
248`,
249 Args: cobra.NoArgs,
250 RunE: func(cmd *cobra.Command, args []string) error {
251 return RootCmd.GenZshCompletion(os.Stdout)
252 },
253 })
254
255 return cmd
256
257}
258
259// convertJSON converts JSON hierarchical config objects into a flattened map fulfilling the
260// z.SuperFlag string format so that Viper can correctly set z.SuperFlag config options for the

Callers 1

initCmdsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected