fix(tunnel): parse flags after the <sandbox> positional#66
Open
pratikbin wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
createos sandbox tunnel my-box --remote 8000fails with--remote <port> is required— even though that exact flags-after-positional form is shown in the command's own--helpexamples.Root cause: urfave/cli v2 stops flag parsing at the first positional argument. The
editcommand already documents and works around this with a hand-rolledparseEditArgs;tunnelnever got the equivalent, so--remote/--local/--bindplaced after<sandbox>are silently dropped.This also breaks the createos-sandbox Claude plugin, whose
cosdriver invokestunnelin exactly this order — every/createos-sandbox:tunneldied on it.Fix
Add
parseTunnelArgs, mirroringparseEditArgs: seed fromc.*(keeps flags placed before the positional working), then re-scan the raw args so a later--remote/--local/--bindin any position wins. Handles both--flag valueand--flag=value.Verification
Built a linux/amd64 binary and ran against a live sandbox — all three now succeed:
tunnel <id> --remote 9090 --local 9091(was broken)ERROR --remote requiredForwardingtunnel <id> --remote=9093 --local=9094ERRORForwardingtunnel --remote 9095 --local 9096 <id>(flags-first)go build/go vet/gofmt/golangci-lintclean.