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..f48948a022 100644 --- a/go.mod +++ b/go.mod @@ -4,10 +4,10 @@ go 1.21 require ( github.com/pelletier/go-toml v1.9.5 - github.com/rsteube/carapace v0.49.1 + github.com/rsteube/carapace v0.49.2 github.com/rsteube/carapace-bridge v0.2.12 github.com/rsteube/carapace-shlex v0.1.2 - github.com/rsteube/carapace-spec v0.14.1 + github.com/rsteube/carapace-spec v0.15.0 github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 golang.org/x/mod v0.15.0 diff --git a/go.sum b/go.sum index c33d9026e3..41457d7e91 100644 --- a/go.sum +++ b/go.sum @@ -16,16 +16,16 @@ github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3v github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rsteube/carapace v0.49.1 h1:ljGQpEkSATpvAnP6eO7Bc1iLJljxgfpCJoCPA/EkQlU= -github.com/rsteube/carapace v0.49.1/go.mod h1:syVOvI8e2rEEK/9aMZxfWuHvcnQK/EcnTV4roClEnLE= +github.com/rsteube/carapace v0.49.2 h1:BMtZK/iGeGFF2cAIn+x0zM46ZbNt7OM+p18sHHXpXm4= +github.com/rsteube/carapace v0.49.2/go.mod h1:syVOvI8e2rEEK/9aMZxfWuHvcnQK/EcnTV4roClEnLE= github.com/rsteube/carapace-bridge v0.2.12 h1:d1kgjgqrmgOa7lHLj/b/esJv692kHSQvTXhmzdx8dwQ= github.com/rsteube/carapace-bridge v0.2.12/go.mod h1:dT8ZptEIYd4zyg5CnPPr+hiLDukPu+lZLcNeyU2Wy2w= github.com/rsteube/carapace-pflag v0.2.0 h1:EYqFO9Haib3NDCPqKu0VxOGi9YQBkXk1IzlHdT0M0vw= github.com/rsteube/carapace-pflag v0.2.0/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/rsteube/carapace-shlex v0.1.2 h1:ZKjhIfXoCkEnzensMglTaLbkNOaLkmM8SCRshpJKx6s= github.com/rsteube/carapace-shlex v0.1.2/go.mod h1:zPw1dOFwvLPKStUy9g2BYKanI6bsQMATzDMYQQybo3o= -github.com/rsteube/carapace-spec v0.14.1 h1:9DckR9UhpHPcHwOYOpiCPNpsEarc6MFybr9lWTdKEao= -github.com/rsteube/carapace-spec v0.14.1/go.mod h1:EyrGR4+EgH/xtueZo01gfWgCzLqjCpef/kdiC+AYS5M= +github.com/rsteube/carapace-spec v0.15.0 h1:alSQo4qQ8XsyOY9FgpfWNYglYy2PRR93KIQ0oxpiteI= +github.com/rsteube/carapace-spec v0.15.0/go.mod h1:fnR0fPoAVV2ET7nPw5fT89jNBQGgUAF1nmkRvy8zT3M= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=