Skip to content

Commit 713ed83

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]> (cherry picked from commit 5a99022) Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 2dc9daa commit 713ed83

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
@@ -186,16 +186,6 @@ func DisableFlagsInUseLine(cmd *cobra.Command) {
186186
})
187187
}
188188

189-
// HasCompletionArg returns true if a cobra completion arg request is found.
190-
func HasCompletionArg(args []string) bool {
191-
for _, arg := range args {
192-
if arg == cobra.ShellCompRequestCmd || arg == cobra.ShellCompNoDescRequestCmd {
193-
return true
194-
}
195-
}
196-
return false
197-
}
198-
199189
var helpCommand = &cobra.Command{
200190
Use: "help [command]",
201191
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)