Skip to content

fix(tunnel): parse flags after the <sandbox> positional#66

Open
pratikbin wants to merge 1 commit into
mainfrom
fix/tunnel-flags-after-positional
Open

fix(tunnel): parse flags after the <sandbox> positional#66
pratikbin wants to merge 1 commit into
mainfrom
fix/tunnel-flags-after-positional

Conversation

@pratikbin

Copy link
Copy Markdown
Contributor

Problem

createos sandbox tunnel my-box --remote 8000 fails with --remote <port> is required — even though that exact flags-after-positional form is shown in the command's own --help examples.

Root cause: urfave/cli v2 stops flag parsing at the first positional argument. The edit command already documents and works around this with a hand-rolled parseEditArgs; tunnel never got the equivalent, so --remote/--local/--bind placed after <sandbox> are silently dropped.

This also breaks the createos-sandbox Claude plugin, whose cos driver invokes tunnel in exactly this order — every /createos-sandbox:tunnel died on it.

Fix

Add parseTunnelArgs, mirroring parseEditArgs: seed from c.* (keeps flags placed before the positional working), then re-scan the raw args so a later --remote/--local/--bind in any position wins. Handles both --flag value and --flag=value.

Verification

Built a linux/amd64 binary and ran against a live sandbox — all three now succeed:

invocation before after
tunnel <id> --remote 9090 --local 9091 (was broken) ERROR --remote required Forwarding
tunnel <id> --remote=9093 --local=9094 ERROR Forwarding
tunnel --remote 9095 --local 9096 <id> (flags-first)

go build / go vet / gofmt / golangci-lint clean.

urfave/cli v2 stops flag parsing at the first positional argument, causing `tunnel my-box --remote 8000` to drop the flag. Add `parseTunnelArgs` to re‑scan raw args so `--remote`, `--local` and `--bind` work in any position, mirroring the edit command’s behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant