From d894d3a15b2b821c1ffe9d67eb317691cbd96249 Mon Sep 17 00:00:00 2001 From: Marcus Ramberg Date: Sun, 28 Sep 2025 21:32:00 +0200 Subject: [PATCH] Enable completion support for cli (#5552) Co-authored-by: Robert Kaussow --- cli/internal/config/config.go | 2 +- cmd/cli/app.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cli/internal/config/config.go b/cli/internal/config/config.go index 274572c679..8a6b221f00 100644 --- a/cli/internal/config/config.go +++ b/cli/internal/config/config.go @@ -31,7 +31,7 @@ func (c *Config) MergeIfNotSet(c2 *Config) { } } -var skipSetupForCommands = []string{"setup", "help", "h", "version", "update", "lint", "exec", ""} +var skipSetupForCommands = []string{"setup", "help", "h", "version", "update", "lint", "exec", "completion", ""} func Load(ctx context.Context, c *cli.Command) error { if firstArg := c.Args().First(); slices.Contains(skipSetupForCommands, firstArg) { diff --git a/cmd/cli/app.go b/cmd/cli/app.go index 301ec61f4f..2cdd623664 100644 --- a/cmd/cli/app.go +++ b/cmd/cli/app.go @@ -41,6 +41,10 @@ func newApp() *cli.Command { app.Before = common.Before app.After = common.After app.Suggest = true + app.ConfigureShellCompletionCommand = func(c *cli.Command) { + c.Hidden = false + c.Usage = "generate completion script for the specified shell" + } app.Commands = []*cli.Command{ admin.Command, exec.Command,