From c81e05eed808290cecf200812cb968aa4f4b356b Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 3 Dec 2025 11:36:34 +0100 Subject: [PATCH] add shell completion for "docker stack deploy --compose-file" With this patch: docker stack deploy -c .codecov.yml contrib/ e2e/ pkg/ .git/ build/ debian/ experimental/ ... docker stack deploy -c contrib/otel/ compose.yaml otelcol.yaml prom.yaml Note that filtering for the file-extension only appears to be functional on bash, but not (currently) working on other shells (at least not on Fish). Signed-off-by: Sebastiaan van Stijn --- cli/command/stack/deploy.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cli/command/stack/deploy.go b/cli/command/stack/deploy.go index 3618870f60d2..2e8a2b09530a 100644 --- a/cli/command/stack/deploy.go +++ b/cli/command/stack/deploy.go @@ -51,7 +51,12 @@ func newDeployCommand(dockerCLI command.Cli) *cobra.Command { flags := cmd.Flags() flags.StringSliceVarP(&opts.composefiles, "compose-file", "c", []string{}, `Path to a Compose file, or "-" to read from stdin`) - flags.SetAnnotation("compose-file", "version", []string{"1.25"}) + _ = flags.SetAnnotation("compose-file", "version", []string{"1.25"}) + // Provide tab-completion for filenames. On Bash, this is constrained to the + // ".yaml" and ".yml" file-extensions, but this doesn't appear to be supported + // by other shells. + _ = cmd.MarkFlagFilename("compose-file", "yaml", "yml") + flags.BoolVar(&opts.sendRegistryAuth, "with-registry-auth", false, "Send registry authentication details to Swarm agents") flags.BoolVar(&opts.prune, "prune", false, "Prune services that are no longer referenced") flags.SetAnnotation("prune", "version", []string{"1.27"})