From 39599cfaf5433b63c341cca9a0c47a2152529225 Mon Sep 17 00:00:00 2001 From: rsteube Date: Wed, 14 Feb 2024 11:32:48 +0100 Subject: [PATCH] git: branch - added missing flags --- cmd/carapace/cmd/codegen.go | 4 ++-- cmd/carapace/cmd/spec.go | 8 +++++--- completers/git_completer/cmd/branch.go | 10 +++++++++- go.mod | 2 ++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/cmd/carapace/cmd/codegen.go b/cmd/carapace/cmd/codegen.go index 913a78b46b..54f444c862 100644 --- a/cmd/carapace/cmd/codegen.go +++ b/cmd/carapace/cmd/codegen.go @@ -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]) }, } diff --git a/cmd/carapace/cmd/spec.go b/cmd/carapace/cmd/spec.go index 903dc79447..f230dd9e39 100644 --- a/cmd/carapace/cmd/spec.go +++ b/cmd/carapace/cmd/spec.go @@ -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) { diff --git a/completers/git_completer/cmd/branch.go b/completers/git_completer/cmd/branch.go index 803e17fbba..7e0bb33cd0 100644 --- a/completers/git_completer/cmd/branch.go +++ b/completers/git_completer/cmd/branch.go @@ -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.") @@ -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 s tracking information so is considered 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..remote and branch..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..remote and branch..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 .") + 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(), @@ -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( diff --git a/go.mod b/go.mod index 817ebf89f3..2155cb265c 100644 --- a/go.mod +++ b/go.mod @@ -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/