fix(remote): --profile flag on remote add consumed by global parser#416
Merged
asheshgoplani merged 2 commits intoasheshgoplani:mainfrom Mar 26, 2026
Merged
Conversation
…arser `extractProfileFlag` greedily consumed all --profile/−p flags from the entire arg list, including those intended for subcommands like `remote add`. This meant `agent-deck remote add srv user@host --profile dev` would set the global profile to "dev" and pass no --profile to handleRemoteAdd, resulting in an empty profile in the remote config. Fix: stop scanning for the global -p/--profile flag once the first positional argument (the subcommand) is encountered. Flags before the subcommand are global; flags after it pass through to the subcommand handler. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Go's flag package accepts both -flag and --flag, but reorderRemoteArgs only registered the --flag form in its valueFlags map. When a user passed -profile (single dash, as shown in the help text), the value was not consumed with the flag and ended up as a stray positional arg, causing the profile to be silently ignored. Register both -flag and --flag forms in the valueFlags map. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
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.
Summary
Fixes #415
extractProfileFlag()now stops scanning for-p/--profileonce it hits the first positional argument (the subcommand)--profilenot consumed, and both global-pand subcommand--profilecoexistingTest plan
TestNestedSessionAllowsCLICommandssubtests passsubcommand_profile_flag_not_consumed— verifiesremote add ... --profile devleaves profile in remaining argsglobal_and_subcommand_profile_flags— verifies-p work remote add ... --profile devcorrectly splits global vs subcommand profilecmd/agent-decktests pass (go test ./cmd/agent-deck/ -v)agent-deck remote add test user@host --profile myprofile && agent-deck remote list --jsonshows correct profile🤖 Generated with Claude Code