Skip to content

Commit 512db84

Browse files
Fix argument validation for --set-default flag
- Replace static cobra.RangeArgs(1, 2) with custom validation function - Allow 0 arguments when --set-default flag is provided - Maintain 1-2 argument requirement for normal workspace operations - Resolves issue where 'brev open --set-default cursor' failed with arg validation error Co-Authored-By: Alec Fong <alecsanf@usc.edu>
1 parent 0e3c18b commit 512db84

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

pkg/cmd/open/open.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,13 @@ func NewCmdOpen(t *terminal.Terminal, store OpenStore, noLoginStartStore OpenSto
6565
Short: "[beta] open VSCode or Cursor to your workspace",
6666
Long: openLong,
6767
Example: openExample,
68-
Args: cmderrors.TransformToValidationError(cobra.RangeArgs(1, 2)),
68+
Args: cmderrors.TransformToValidationError(func(cmd *cobra.Command, args []string) error {
69+
setDefaultFlag, _ := cmd.Flags().GetString("set-default")
70+
if setDefaultFlag != "" {
71+
return cobra.NoArgs(cmd, args)
72+
}
73+
return cobra.RangeArgs(1, 2)(cmd, args)
74+
}),
6975
ValidArgsFunction: completions.GetAllWorkspaceNameCompletionHandler(noLoginStartStore, t),
7076
RunE: func(cmd *cobra.Command, args []string) error {
7177
if setDefault != "" {

0 commit comments

Comments
 (0)