Skip to content
Myr

Provide option to hide default 'completion' cmd (#1541)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fixes #1507

authored by Marc Khouzam · committed by GitHub · parent ee75a2b · Browse files · 2 files+18 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>

Diff stats

2 files+18 added−0 removed

  • other:+18 added−0 removed

2 files+18 added−0 removed

modified:completions_test.go+15 added
2396 unmodified lines
2397 // Re-enable for next test2398 rootCmd.CompletionOptions.DisableDescriptions = false2399 // Remove completion command for the next test2400 removeCompCmd(rootCmd)24012402 // Test that the 'completion' command can be hidden2403 rootCmd.CompletionOptions.HiddenDefaultCmd = true2404 assertNoErr(t, rootCmd.Execute())2405 compCmd, _, err = rootCmd.Find([]string{compCmdName})2406 if err != nil {2407 t.Errorf("Unexpected error: %v", err)2408 }2409 if compCmd.Hidden == false {2410 t.Error("Default 'completion' command should be hidden but it is not")2411 }2412 // Re-enable for next test2413 rootCmd.CompletionOptions.HiddenDefaultCmd = false2414 // Remove completion command for the next test2415 removeCompCmd(rootCmd)2416}24172418func TestCompleteCompletion(t *testing.T) {2419 rootCmd := &Command{Use: "root", Args: NoArgs, Run: emptyRun}
202 unmodified lines
modified:completions.go+3 added
91 unmodified lines
92 DisableNoDescFlag bool93 // DisableDescriptions turns off all completion descriptions for shells94 // that support them95 DisableDescriptions bool96 // HiddenDefaultCmd makes the default 'completion' command hidden97 HiddenDefaultCmd bool98}99100// NoFileCompletions can be used to disable file completion for commands that should101// not trigger file completions.
504 unmodified lines
606See each sub-command's help for details on how to use the generated script.607`, c.Root().Name()),608 Args: NoArgs,609 ValidArgsFunction: NoFileCompletions,610 Hidden: c.CompletionOptions.HiddenDefaultCmd,611 }612 c.AddCommand(completionCmd)613614 out := c.OutOrStdout()
187 unmodified lines