diff --git a/completers/git_completer/cmd/checkoutIndex.go b/completers/git_completer/cmd/checkoutIndex.go new file mode 100644 index 0000000000..71f4d24222 --- /dev/null +++ b/completers/git_completer/cmd/checkoutIndex.go @@ -0,0 +1,43 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var checkoutIndexCmd = &cobra.Command{ + Use: "checkout-index", + Short: "Copy files from the index to the working tree", + Run: func(cmd *cobra.Command, args []string) {}, + GroupID: groups[group_low_level_manipulator].ID, +} + +func init() { + carapace.Gen(checkoutIndexCmd).Standalone() + + checkoutIndexCmd.Flags().BoolP("all", "a", false, "check out all files in the index") + checkoutIndexCmd.Flags().BoolP("force", "f", false, "force overwrite of existing files") + checkoutIndexCmd.Flags().Bool("ignore-skip-worktree-bits", false, "do not skip files with skip-worktree set") + checkoutIndexCmd.Flags().BoolP("index", "u", false, "update stat information in the index file") + checkoutIndexCmd.Flags().BoolP("no-create", "n", false, "don't checkout new files") + checkoutIndexCmd.Flags().String("prefix", "", "when creating files, prepend ") + checkoutIndexCmd.Flags().BoolP("quiet", "q", false, "no warning for existing files and files not in index") + checkoutIndexCmd.Flags().String("stage", "", "copy out the files from named stage") + checkoutIndexCmd.Flags().Bool("stdin", false, "read list of paths from the standard input") + checkoutIndexCmd.Flags().Bool("temp", false, "write the content to temporary files") + checkoutIndexCmd.Flags().BoolS("z", "z", false, "paths are separated with NUL character") + rootCmd.AddCommand(checkoutIndexCmd) + + carapace.Gen(checkoutIndexCmd).FlagCompletion(carapace.ActionMap{ + "stage": carapace.ActionValues("1", "2", "3", "all"), + }) + + carapace.Gen(checkoutIndexCmd).PositionalAnyCompletion( + carapace.ActionCallback(func(c carapace.Context) carapace.Action { + if checkoutIndexCmd.Flag("stdin").Changed { + return carapace.ActionValues() + } + return carapace.ActionFiles() + }), + ) +} diff --git a/completers/git_completer/cmd/checkout_index_generated.go b/completers/git_completer/cmd/checkout_index_generated.go deleted file mode 100644 index ee572b1f52..0000000000 --- a/completers/git_completer/cmd/checkout_index_generated.go +++ /dev/null @@ -1,28 +0,0 @@ -package cmd - -import ( - "github.com/rsteube/carapace" - "github.com/spf13/cobra" -) - -var checkout_indexCmd = &cobra.Command{ - Use: "checkout-index", - Short: "Copy files from the index to the working tree", - Run: func(cmd *cobra.Command, args []string) {}, - GroupID: groups[group_low_level_manipulator].ID, -} - -func init() { - carapace.Gen(checkout_indexCmd).Standalone() - checkout_indexCmd.Flags().BoolP("all", "a", false, "check out all files in the index") - checkout_indexCmd.Flags().BoolP("force", "f", false, "force overwrite of existing files") - checkout_indexCmd.Flags().BoolP("index", "u", false, "update stat information in the index file") - checkout_indexCmd.Flags().BoolP("no-create", "n", false, "don't checkout new files") - checkout_indexCmd.Flags().String("prefix", "", "when creating files, prepend ") - checkout_indexCmd.Flags().BoolP("quiet", "q", false, "no warning for existing files and files not in index") - checkout_indexCmd.Flags().String("stage", "", "copy out the files from named stage") - checkout_indexCmd.Flags().Bool("stdin", false, "read list of paths from the standard input") - checkout_indexCmd.Flags().Bool("temp", false, "write the content to temporary files") - checkout_indexCmd.Flags().BoolS("z", "z", false, "paths are separated with NUL character") - rootCmd.AddCommand(checkout_indexCmd) -}