Skip to content

fix(remote): --profile flag on remote add consumed by global parser#416

Merged
asheshgoplani merged 2 commits intoasheshgoplani:mainfrom
afterthought:fix/remote-add-profile-flag
Mar 26, 2026
Merged

fix(remote): --profile flag on remote add consumed by global parser#416
asheshgoplani merged 2 commits intoasheshgoplani:mainfrom
afterthought:fix/remote-add-profile-flag

Conversation

@afterthought
Copy link
Copy Markdown
Contributor

Summary

Fixes #415

  • extractProfileFlag() now stops scanning for -p/--profile once it hits the first positional argument (the subcommand)
  • Flags before the subcommand are global; flags after it pass through to the subcommand handler
  • Added two test cases: subcommand --profile not consumed, and both global -p and subcommand --profile coexisting

Test plan

  • Existing TestNestedSessionAllowsCLICommands subtests pass
  • New test: subcommand_profile_flag_not_consumed — verifies remote add ... --profile dev leaves profile in remaining args
  • New test: global_and_subcommand_profile_flags — verifies -p work remote add ... --profile dev correctly splits global vs subcommand profile
  • All cmd/agent-deck tests pass (go test ./cmd/agent-deck/ -v)
  • Manual: agent-deck remote add test user@host --profile myprofile && agent-deck remote list --json shows correct profile

🤖 Generated with Claude Code

afterthought and others added 2 commits March 21, 2026 19:44
…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]>
@asheshgoplani asheshgoplani merged commit d43fe3e into asheshgoplani:main Mar 26, 2026
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.

remote add --profile flag silently ignored (consumed by global parser)

2 participants