Repository navigation
fix(alias): forward help flags through aliases that accept arguments - #4856
Conversation
worktrunk-bot
left a comment
There was a problem hiding this comment.
For any alias whose template references args, wt <alias> --help now runs the whole alias. Nothing upstream catches the flag: try_intercept_alias_help was the only --help/-h check on the alias path, and run_alias gets everything it lets through. That's what you want for a wrapper like sw = "wt switch {{ args }}". Two common shapes don't behave as a help request:
- Pipelines.
argsis collected across every step, so inrelease = ["cargo publish", "gh release create {{ args }}"]the help request runscargo publishfor real beforeghever sees--help. - Commands that don't read
--helpas help. Withdeploy = "./scripts/deploy.sh {{ args }}"or"echo building && make {{ args }}", the alias does its normal work and passes--helpalong as an ordinary argument.
Under the current intercept a user can type --help to find out what an alias does without running it. AliasOptions::parse protects --dry-run for the same reason: it is "the one flag whose purpose is not doing the thing". This change makes that protection depend on whether the template mentions args, and the user typing the command usually can't see the template. #2305 asks for feedback on exactly this, so it's a maintainer decision. One narrower rule would forward help only when the alias is a single command whose first word is wt (the sw case in the PR body) and keep the hint everywhere else.
The new docs row ends with "including binding --help=value to help". Few readers will ever write an alias that binds a help variable, and the general variable-binding docs already cover how --KEY=VALUE works. Consider cutting that clause.
|
I reproduced this with |
|
No, I'd keep the current routing. It matches what max-sixty leaned toward on #2305: forward One small thing is still open from my review: the docs row (and its copy in |
worktrunk-bot
left a comment
There was a problem hiding this comment.
The doc comment on test_alias_help_flag_after_double_dash_forwards in tests/integration_tests/step_alias.rs now says the wrong thing. It calls wt <alias> -- --help "the documented escape" that "bypasses the intercept". After this change, deploy = "echo {{ args }}" never hits the intercept, and the hint no longer mentions -- --help. The new test's probe -- --help case already covers that path. Either update the comment to say what the test checks now (literal -- still forwards), or drop the test as redundant.
I can push that fix together with the --help=value clause cut from my earlier comment, regenerating the doc mirrors at the same time. Just say so.
|
|
|
Okay, @worktrunk-bot, could you rerun the failed macOS job once? |
|
Reran the failed |
|
@worktrunk-bot Thank you Mr. bot! |
With
sw = "wt switch {{ args }}",wt sw --helpnow prints the same help aswt switch --help. The short-hspelling passes through too. Bothwt swandwt step swuse the same rule.Aliases that bind
helpkeep their existing argument parsing. For a fixed alias,--helpand-hshow how to inspect it without running its body.I checked both routes with the branch-built CLI, compared short and long help with direct
wt switchoutput, and verified that requesting help for a fixed alias left its sentinel file absent. All 94 alias integration tests and the full pre-merge gate passed.Another option is to let ordinary argument handling decide every invocation, including fixed aliases. I’m happy to replace this PR if you prefer that behavior.
Closes #2305.