Skip to content

Commit

Permalink
Make 0 arg state for stack branch more user friendly (#445)
Browse files Browse the repository at this point in the history
We suppress cobra usage output across the board, but in the 0 arg case for stack branch we should show the user the usage rather than a generic "error: accepts between 1 and 2 arg(s), received 0"
  • Loading branch information
tulioz authored Nov 1, 2024
1 parent 22495d4 commit ed184fe
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cmd/av/stack_branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@ If the --rename/-m flag is given, the current branch is renamed to the name
given as the first argument to the command. Branches should only be renamed
with this command (not with git branch -m ...) because av needs to update
internal tracking metadata that defines the order of branches within a stack.`,
SilenceUsage: true,
Args: cobra.RangeArgs(1, 2),
Args: cobra.RangeArgs(0, 2),
RunE: func(cmd *cobra.Command, args []string) (reterr error) {
if len(args) == 0 {
// The only time we don't want to suppress the usage message is when
// a user runs `av branch` with no arguments.
return cmd.Usage()
}

repo, err := getRepo()
if err != nil {
return err
Expand Down

0 comments on commit ed184fe

Please sign in to comment.