Skip to content

Commit 7c96465

Browse files
feat: accept pool name as positional arg in browser-pools create (#110)
## Summary Allow `kernel browser-pools create my-pool` as shorthand for `kernel browser-pools create --name my-pool`. The `--name` flag still works for backward compatibility. added this because I forget to add `--name` ## Testing Previously we created the pool and ignored the passed name ``` ❯ kernel browser-pools create test --size 1 SUCCESS Created browser pool a8e4g5n4doawmwwy7dip8qqz ``` Now we are creating the pool and the name is set. `--name` still works ``` ❯ ./bin/kernel browser-pools create test --size 1 SUCCESS Created browser pool test (pctp2h92siimy4jxks89g33g) ❯ ./bin/kernel browser-pools create --name test --size 1 ERROR Conflict: A pool with this name already exists ``` <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Small CLI parsing change limited to `browser-pools create`; low blast radius aside from potential behavior change when both `--name` and a positional name are supplied. > > **Overview** > `kernel browser-pools create` now accepts an optional positional `[name]` argument as a shorthand for `--name`. > > The command enforces mutual exclusivity between the positional name and `--name` (returns an error if both are provided) and updates the Cobra command usage/arg validation accordingly. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 46881b1. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent afd1bfe commit 7c96465

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

cmd/browser_pools.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,9 @@ var browserPoolsListCmd = &cobra.Command{
404404
}
405405

406406
var browserPoolsCreateCmd = &cobra.Command{
407-
Use: "create",
407+
Use: "create [name]",
408408
Short: "Create a new browser pool",
409+
Args: cobra.MaximumNArgs(1),
409410
RunE: runBrowserPoolsCreate,
410411
}
411412

@@ -518,6 +519,12 @@ func runBrowserPoolsCreate(cmd *cobra.Command, args []string) error {
518519
client := getKernelClient(cmd)
519520

520521
name, _ := cmd.Flags().GetString("name")
522+
if len(args) > 0 && args[0] != "" {
523+
if cmd.Flags().Changed("name") {
524+
return fmt.Errorf("cannot specify pool name as both a positional argument and --name flag")
525+
}
526+
name = args[0]
527+
}
521528
size, _ := cmd.Flags().GetInt64("size")
522529
fillRate, _ := cmd.Flags().GetInt64("fill-rate")
523530
timeout, _ := cmd.Flags().GetInt64("timeout")

0 commit comments

Comments
 (0)