Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git: branch - added missing flags #2243

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
Loading