From be6aa804a5f1a080e1e5f0f46aa53ec4c563fd45 Mon Sep 17 00:00:00 2001 From: rsteube Date: Tue, 31 Oct 2023 12:04:07 +0100 Subject: [PATCH] git: replace --- completers/git_completer/cmd/replace.go | 44 +++++++++++++++++++ .../git_completer/cmd/replace_generated.go | 26 ----------- 2 files changed, 44 insertions(+), 26 deletions(-) create mode 100644 completers/git_completer/cmd/replace.go delete mode 100644 completers/git_completer/cmd/replace_generated.go diff --git a/completers/git_completer/cmd/replace.go b/completers/git_completer/cmd/replace.go new file mode 100644 index 0000000000..ca63261adc --- /dev/null +++ b/completers/git_completer/cmd/replace.go @@ -0,0 +1,44 @@ +package cmd + +import ( + "github.com/rsteube/carapace" + "github.com/spf13/cobra" +) + +var replaceCmd = &cobra.Command{ + Use: "replace", + Short: "Create, list, delete refs to replace objects", + Run: func(cmd *cobra.Command, args []string) {}, + GroupID: groups[group_manipulator].ID, +} + +func init() { + carapace.Gen(replaceCmd).Standalone() + + replaceCmd.Flags().Bool("convert-graft-file", false, "Creates graft commits for all entries in $GIT_DIR/info/grafts and deletes that file upon success") + replaceCmd.Flags().BoolP("delete", "d", false, "Delete existing replace refs for the given objects") + replaceCmd.Flags().String("edit", "", "Edit an object’s content interactively") + replaceCmd.Flags().BoolP("force", "f", false, "If an existing replace ref for the same object exists, it will be overwritten") + replaceCmd.Flags().String("format", "", "When listing, use the specified ") + replaceCmd.Flags().String("graft", "", "Create a graft commit") + replaceCmd.Flags().StringP("list", "l", "", "List replace refs for objects that match the given pattern") + replaceCmd.Flags().Bool("raw", false, "When editing, provide the raw object contents rather than pretty-printed ones") + rootCmd.AddCommand(replaceCmd) + + replaceCmd.MarkFlagsMutuallyExclusive( + "convert-graft-file", + "delete", + "edit", + "graft", + ) + + carapace.Gen(replaceCmd).FlagCompletion(carapace.ActionMap{ + "format": carapace.ActionValuesDescribed( + "short", "", + "medium", "", + "long", " () → ()", + ), + }) + + // TODO positional completion +} diff --git a/completers/git_completer/cmd/replace_generated.go b/completers/git_completer/cmd/replace_generated.go deleted file mode 100644 index a9bc9a11de..0000000000 --- a/completers/git_completer/cmd/replace_generated.go +++ /dev/null @@ -1,26 +0,0 @@ -package cmd - -import ( - "github.com/rsteube/carapace" - "github.com/spf13/cobra" -) - -var replaceCmd = &cobra.Command{ - Use: "replace", - Short: "Create, list, delete refs to replace objects", - Run: func(cmd *cobra.Command, args []string) {}, - GroupID: groups[group_manipulator].ID, -} - -func init() { - carapace.Gen(replaceCmd).Standalone() - replaceCmd.Flags().Bool("convert-graft-file", false, "convert existing graft file") - replaceCmd.Flags().BoolP("delete", "d", false, "delete replace refs") - replaceCmd.Flags().BoolP("edit", "e", false, "edit existing object") - replaceCmd.Flags().BoolP("force", "f", false, "replace the ref if it exists") - replaceCmd.Flags().String("format", "", "use this format") - replaceCmd.Flags().BoolP("graft", "g", false, "change a commit's parents") - replaceCmd.Flags().BoolP("list", "l", false, "list replace refs") - replaceCmd.Flags().Bool("raw", false, "do not pretty-print contents for --edit") - rootCmd.AddCommand(replaceCmd) -}