Skip to content

Commit

Permalink
git: branch - added missing flags
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Feb 14, 2024
1 parent 7f9bc23 commit ffd1af7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cmd/carapace/cmd/codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ var codegenCmd = &cobra.Command{
Use: "--codegen [spec]",
Short: "",
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
codegen(args[0])
RunE: func(cmd *cobra.Command, args []string) error {
return codegen(args[0])
},
}

Expand Down
8 changes: 5 additions & 3 deletions cmd/carapace/cmd/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ func loadSpec(path string) (string, *spec.Command, error) {
return abs, &specCmd, nil
}

func codegen(path string) {
func codegen(path string) error {
// TODO yuck - all this needs some cleanup
if _, spec, err := loadSpec(path); err == nil {
spec.Codegen()
_, spec, err := loadSpec(path)
if err != nil {
return err
}
return spec.Codegen()
}

func specCompletion(path string, args ...string) (string, error) {
Expand Down
10 changes: 9 additions & 1 deletion completers/git_completer/cmd/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func init() {
branchCmd.Flags().String("abbrev", "", "Alter the sha1s minimum display length in the output listing.")
branchCmd.Flags().BoolP("all", "a", false, "List both remote-tracking branches and local branches.")
branchCmd.Flags().String("color", "", "Color branches to highlight current, local, and remote-tracking branches.")
branchCmd.Flags().Bool("column", false, "Display branch listing in columns")
branchCmd.Flags().String("contains", "", "Only list branches which contain the specified commit (HEAD if not specified).")
branchCmd.Flags().BoolP("copy", "c", false, "Copy a branch and the corresponding reflog.")
branchCmd.Flags().Bool("create-reflog", false, "Create the branchs reflog.")
Expand All @@ -35,19 +36,25 @@ func init() {
branchCmd.Flags().BoolP("move", "m", false, "Move/rename a branch and the corresponding reflog.")
branchCmd.Flags().Bool("no-abbrev", false, "Display the full sha1s in the output listing rather than abbreviating them.")
branchCmd.Flags().Bool("no-color", false, "Turn off branch colors, even when the configuration file gives the default to color output.")
branchCmd.Flags().Bool("no-column", false, "Do not display branch listing in columns")
branchCmd.Flags().String("no-contains", "", "Only list branches which dont contain the specified commit (HEAD if not specified).")
branchCmd.Flags().String("no-merged", "", "Only list branches whose tips are not reachable from the specified commit (HEAD if not specified).")
branchCmd.Flags().Bool("no-track", false, "Do not set up upstream configuration, even if the branch.autoSetupMerge configuration variable is true.")
branchCmd.Flags().Bool("omit-empty", false, "Do not print a newline after formatted refs")
branchCmd.Flags().String("points-at", "", "Only list branches of the given object.")
branchCmd.Flags().BoolP("quiet", "q", false, "Be more quiet when creating or deleting a branch, suppressing non-error messages.")
branchCmd.Flags().Bool("recurse-submodules", false, "Causes the current command to recurse into submodules")
branchCmd.Flags().BoolP("remotes", "r", false, "List or delete (if used with -d) the remote-tracking branches.")
branchCmd.Flags().String("set-upstream-to", "", "Set up <branchname>s tracking information so <upstream> is considered <branchname>s upstream branch.")
branchCmd.Flags().Bool("show-current", false, "Print the name of the current branch.")
branchCmd.Flags().String("sort", "", "Sort based on the key given.")
branchCmd.Flags().BoolP("track", "t", false, "When creating a new branch, set up branch.<name>.remote and branch.<name>.merge configuration entries to mark the start-point branch as upstream from the new branch.")
branchCmd.Flags().StringP("track", "t", "", "When creating a new branch, set up branch.<name>.remote and branch.<name>.merge configuration entries to mark the start-point branch as upstream from the new branch.")
branchCmd.Flags().Bool("unset-upstream", false, "Remove the upstream information for <branchname>.")
branchCmd.Flags().CountP("verbose", "v", "Verbose output")
rootCmd.AddCommand(branchCmd)

branchCmd.Flag("track").NoOptDefVal = " "

carapace.Gen(branchCmd).FlagCompletion(carapace.ActionMap{
"D": git.ActionRefs(git.RefOption{}.Default()),
"color": git.ActionColorModes(),
Expand All @@ -59,6 +66,7 @@ func init() {
"points-at": git.ActionRefs(git.RefOption{RemoteBranches: true, Tags: true}),
"set-upstream-to": git.ActionRefs(git.RefOption{RemoteBranches: true, Tags: true}),
"sort": git.ActionFieldNames(),
"track": carapace.ActionValues("direct", "inherit"),
})

carapace.Gen(branchCmd).PositionalAnyCompletion(
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ require (
)

replace github.com/spf13/pflag => github.com/rsteube/carapace-pflag v0.2.0

replace github.com/rsteube/carapace-spec => ../carapace-spec/

0 comments on commit ffd1af7

Please sign in to comment.