Repository navigation
Fix leading '--' stripping to preserve command data - #187
Conversation
Ahoy removed every '--' a user typed, so a separator meant as data never reached the wrapped tool. That silently changed the request for anything needing one of its own: kubectl exec, npm run, cargo run, git checkout. The worst case is git. With a branch and a file sharing a name, 'ahoy git checkout -- deploy' arrived as 'git checkout deploy', so a request to discard edits to a file switched branch instead and left the edits in place. The strip came from ahoy-cli#101, fixing ahoy-cli#100 ('ahoy up -- --build' reaching docker-compose as '-- --build'). The intent there was that a leading '--' shields what follows, which urfave/cli needed at the time; the implementation stripped every occurrence instead of the first. Since ahoy-cli#182 ahoy no longer parses a command's arguments at all, so a leading '--' is now only a readability habit, but scripts still use it and honouring it costs nothing. Now: a leading '--' is consumed, every later one is the command's data. Claude-Session: https://claude.ai/code/session_01629NFuQxTr678Tdh8AD39d
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. WalkthroughAhoy now removes only a leading ChangesSeparator pass-through
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change limits separator removal to the leading Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Fixes #186. Ahoy removed every -- a user typed on the command line, so a separator meant as data never reached the wrapped tool. Now a leading -- is consumed, as it always was, and every later one is the command's own data.
This came out of the discussion on #163.
The issue
Plenty of tools need a -- of their own, and stripping it silently changed what the user asked for:
ahoy k exec mypod -- ls /appkubectl exec mypod ls /appkubectl exec mypod -- ls /appahoy npm run build -- --verbosenpm run build --verbosenpm run build -- --verboseahoy cargo run -- --port 8080cargo run --port 8080cargo run -- --port 8080ahoy git checkout -- deploygit checkout deploygit checkout -- deployThe git case is the one that convinced me this was worth doing on its own. With a branch and a file sharing a name, and uncommitted edits to the file:
=== before: on 'main', file 'deploy' edited, branch 'deploy' also exists
running:
ahoy git checkout -- deploySwitched to branch 'deploy'
M deploy
result: branch=deploy file='MY UNSAVED EDITS'
=== after: on 'main', file 'deploy' edited, branch 'deploy' also exists
running:
ahoy git checkout -- deployresult: branch=main file='committed content'
A request to discard edits to a file switched the branch instead and left the edits in place. That is the same shape of failure as #182: the wrapped tool succeeds, having done something other than what was typed.
Original change
The old filter came from #101, fixing #100, where
ahoy up -- --buildreacheddocker-composeas-- --build. The intent was that a leading -- shields what follows, whichurfave/clineeded at the time. The implementation stripped every occurrence rather than the first, and then continued into v3 unchanged.Since #182, Ahoy does not parse a command's arguments at all, so a leading -- is no longer needed for its original purpose. Scripts and aliases still use it though, so it is still honoured, and
ahoy up -- --buildbehaves exactly as it does today.Compatibility
The only behaviour lost is a non-leading -- being silently deleted, which is the defect. A -- written inside the
cmd:body in.ahoy.ymlwas never affected either way, since that string goes to the shell untouched.Closes #186
Summary by CodeRabbit
--separator is consumed.--values when passed to executed commands.