Skip to content

Commit 5a99022

Browse files
committed
cli: remove HasCompletionArg utility
It was only used in a single place and has no external consumers. Move it to where it's used to keep things together. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 53b6fdd commit 5a99022

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

cli/cobra.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -185,16 +185,6 @@ func DisableFlagsInUseLine(cmd *cobra.Command) {
185185
})
186186
}
187187

188-
// HasCompletionArg returns true if a cobra completion arg request is found.
189-
func HasCompletionArg(args []string) bool {
190-
for _, arg := range args {
191-
if arg == cobra.ShellCompRequestCmd || arg == cobra.ShellCompNoDescRequestCmd {
192-
return true
193-
}
194-
}
195-
return false
196-
}
197-
198188
var helpCommand = &cobra.Command{
199189
Use: "help [command]",
200190
Short: "Help about the command",

cmd/docker/docker.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ func runDocker(ctx context.Context, dockerCli *command.DockerCli) error {
451451
return err
452452
}
453453

454-
if cli.HasCompletionArg(args) {
454+
if hasCompletionArg(args) {
455455
// We add plugin command stubs early only for completion. We don't
456456
// want to add them for normal command execution as it would cause
457457
// a significant performance hit.
@@ -504,6 +504,16 @@ func runDocker(ctx context.Context, dockerCli *command.DockerCli) error {
504504
return err
505505
}
506506

507+
// hasCompletionArg returns true if a cobra completion arg request is found.
508+
func hasCompletionArg(args []string) bool {
509+
for _, arg := range args {
510+
if arg == cobra.ShellCompRequestCmd || arg == cobra.ShellCompNoDescRequestCmd {
511+
return true
512+
}
513+
}
514+
return false
515+
}
516+
507517
type versionDetails interface {
508518
CurrentVersion() string
509519
ServerInfo() command.ServerInfo

0 commit comments

Comments
 (0)