From 219d14a50e8a88f97077f9941438f3e7c571d812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Blaise?= Date: Wed, 3 Mar 2021 09:01:47 +0100 Subject: [PATCH] Add completion on play --- cmd/play.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cmd/play.go b/cmd/play.go index 2e6457d..955b0e6 100644 --- a/cmd/play.go +++ b/cmd/play.go @@ -57,6 +57,23 @@ func init() { playCmd.Flags().StringP("vault-password-file", utils.EmptyString, utils.EmptyString, "vault password file") playCmd.Flags().StringSliceP("limit", "l", nil, "further limit selected hosts to an additional pattern") playCmd.Flags().StringSliceP("tags", "t", nil, "only run plays and tasks tagged with these values") + + // Completions + _ = generateCmd.RegisterFlagCompletionFunc("filter", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + path, _ := os.Getwd() + return filterCompletion(toComplete, path) + }) + + _ = generateCmd.RegisterFlagCompletionFunc("playbook", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + path, _ := os.Getwd() + return playbookCompletion(toComplete, path) + }) + + _ = generateCmd.RegisterFlagCompletionFunc("tags", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + path, _ := os.Getwd() + playbookPath, _ := cmd.Flags().GetString("playbook") + return tagsCompletion(toComplete, path, playbookPath) + }) } func play(cmd *cobra.Command, args []string, path string) {