From 713ed839fe117cdaaa5b114de58594f6fac8b2c3 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 7 Aug 2025 00:19:16 +0200 Subject: [PATCH] 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 (cherry picked from commit 5a9902255613ba63e81d97f7581bff9ecb55fe46) Signed-off-by: Sebastiaan van Stijn --- cli/cobra.go | 10 ---------- cmd/docker/docker.go | 12 +++++++++++- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cli/cobra.go b/cli/cobra.go index 7a14b6f483..b3e663423b 100644 --- a/cli/cobra.go +++ b/cli/cobra.go @@ -186,16 +186,6 @@ func DisableFlagsInUseLine(cmd *cobra.Command) { }) } -// HasCompletionArg returns true if a cobra completion arg request is found. -func HasCompletionArg(args []string) bool { - for _, arg := range args { - if arg == cobra.ShellCompRequestCmd || arg == cobra.ShellCompNoDescRequestCmd { - return true - } - } - return false -} - var helpCommand = &cobra.Command{ Use: "help [command]", Short: "Help about the command", diff --git a/cmd/docker/docker.go b/cmd/docker/docker.go index ccd61845a1..ad2cc096f2 100644 --- a/cmd/docker/docker.go +++ b/cmd/docker/docker.go @@ -451,7 +451,7 @@ func runDocker(ctx context.Context, dockerCli *command.DockerCli) error { return err } - if cli.HasCompletionArg(args) { + if hasCompletionArg(args) { // We add plugin command stubs early only for completion. We don't // want to add them for normal command execution as it would cause // a significant performance hit. @@ -504,6 +504,16 @@ func runDocker(ctx context.Context, dockerCli *command.DockerCli) error { return err } +// hasCompletionArg returns true if a cobra completion arg request is found. +func hasCompletionArg(args []string) bool { + for _, arg := range args { + if arg == cobra.ShellCompRequestCmd || arg == cobra.ShellCompNoDescRequestCmd { + return true + } + } + return false +} + type versionDetails interface { CurrentVersion() string ServerInfo() command.ServerInfo