jj
jj copied to clipboard
`jj <alias> --help` works, but `jj help <alias>` does not
Example: Add an alias fetch = git fetch in your config, run jj help fetch. You get error: unrecognized subcommand 'fetch'
I wouldn't say that jj <alias> --help works properly, either.
E.g., if I have an alias aliases.d = ["diff", "-s"], jj d --help is currently the same as jj diff --help. I'd prefer if jj d --help told me that d is an alias. We could also make it print jj diff --help afterwards, or we could not do that.
I think making jj help d act the same way as jj d --help might still be an improvement, though, at least for aliases like your "fetch".
I was hoping this would be a quick in-and-out fix, but it appears that the way help is actually invoked is deep in the internals of clap, so it's not as simple as I hoped. I may come back to this later but I'll unassign for now.
but it appears that the way
helpis actually invoked is deep in the internals of clap
Yes, I suspect we'll need to take over handling of all help messages in order to fix this.
Rather than implementing help manually, it might make sense to go through visible_alias, which makes help work out of the box without having to reimplement it: https://docs.rs/clap/latest/clap/struct.Command.html#method.visible_alias
(i took a look at reimplementing help and it looks decidedly non-trivial, there's lots of digging through clap's reflection API.)
ah, i see, aliases can be multiple commands, they don't correspond 1-1 with a subcommand. so visible_alias won't work.
for anyone picking this up in the future - the way clap does this internally is https://docs.rs/clap_builder/4.4.18/src/clap_builder/builder/command.rs.html#4474-4487
Is there a place where the "not found" error can be checked, and a list of aliases could be listed instead?
@joyously do you mean the "unrecognized subcommand" error? yes, but that place is in clap itself: https://github.com/clap-rs/clap/blob/a7e04a53e4a9e310663a0cdb5bfb0753d84b82bd/clap_builder/src/error/format.rs#L529