Skip to content

Commit

Permalink
git: replace
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Oct 31, 2023
1 parent 458b796 commit be6aa80
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 26 deletions.
44 changes: 44 additions & 0 deletions completers/git_completer/cmd/replace.go
Original file line number Diff line number Diff line change
@@ -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 <format>")
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", "<replaced sha1>",
"medium", "<replaced sha1> → <replacement sha1>",
"long", "<replaced sha1> (<replaced type>) → <replacement sha1> (<replacement type>)",
),
})

// TODO positional completion
}
26 changes: 0 additions & 26 deletions completers/git_completer/cmd/replace_generated.go

This file was deleted.

0 comments on commit be6aa80

Please sign in to comment.