From cdfcc753e06bc717d7e00b0adbb5d40abc8eb2c0 Mon Sep 17 00:00:00 2001 From: Lucas Alvares Gomes Date: Tue, 21 Apr 2026 20:56:19 +0100 Subject: [PATCH] Allow appending args to the configured command Implement "--" passthrough to append extra arguments to the configured command. For example, if the default command is "goose", one can do the following to resume a session: $ bwai -- session -r Signed-off-by: Lucas Alvares Gomes --- README.md | 14 +++++++++++++- cmd/bwai/main.go | 5 ++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c4c4c4a..e04b031 100644 --- a/README.md +++ b/README.md @@ -54,9 +54,21 @@ To skip the shell and launch an agent (or any command) directly, you can either: ```sh bwai --command claude -bwai -c "claude --model gemini-2.0-flash-exp" + ``` +To append arguments to the command configured in `~/.bwai.json`, use `--`: + +```sh +# With "command": ["goose"] in config +bwai -- session -r # runs "goose session -r" to resume a session + +# With "command": ["claude"] in config +bwai -- --model gemini-2.0-flash-exp # runs "claude --model gemini-2.0-flash-exp" +``` + +Everything after `--` is passed as extra arguments to the resolved command. + ## Configuration `bwai` works out of the box with no config file. To customise behaviour, create `~/.bwai.json` as a global config. This can be overridden per-run with the `--config` flag: diff --git a/cmd/bwai/main.go b/cmd/bwai/main.go index fc625a8..48fa370 100644 --- a/cmd/bwai/main.go +++ b/cmd/bwai/main.go @@ -7,6 +7,7 @@ import ( "os" "os/exec" "path/filepath" + "strings" ) func main() { @@ -59,6 +60,8 @@ func main() { if *commandFlag != "" { command = []string{*commandFlag} } + // Append any trailing args after -- to the resolved command + command = append(command, flag.Args()...) fmt.Printf("bwai: sandboxed in %s\n", currentDir) args := []string{ @@ -122,7 +125,7 @@ func main() { // running with --unshare-pid (which it does by default). // By running the command via "bash -i -c goose" the iteractive shell // prevents it from exiting and goose starts normally. - command = append([]string{"bash", "-i", "-c"}, command...) + command = []string{"bash", "-i", "-c", strings.Join(command, " ")} } args = append(args, command...)