jj
jj copied to clipboard
FR: A way to discover names of builtin and user defined templates
Is your feature request related to a problem? Please describe.
There is some minor friction when I want jj log -T
with a template and forget its exact name.
Describe the solution you'd like
A few possible solutions:
- a dedicated
jj
command to print available templates. Cons: too many commands already. -
jj log -T
could print applicable templates in the error (Is there a notion of an applicable template? I don't know yet). Cons: less discoverable and maybe less intuitive. - list templates in
jj log --help
under the-T
argument (Doesclap
allow that?). Cons: also less discoverable.
If 2 and 3 could be done together, perhaps their cons would be less noticeable.
Describe alternatives you've considered
Go to the jj
repo and find the default config or go to the repo with my own config.
Additional context
--
Would be cool to generate extra shell completions, jj -T <tab>
to cycle through them.
Although this yet again requires dynamic completion in clap, eh
Incidentally I've implemented a variant of 2. Shell completion is another story. iirc, clap doesn't support custom completion logic yet.
% jj log -Tbuiltin
Error: Failed to parse template: --> 1:1
|
1 | builtin
| ^-----^
|
= Keyword "builtin" doesn't exist
Hint: Did you mean "builtin_change_id_with_hidden_and_divergent_info", "builtin_log_comfortable", "builtin_log_compact", "builtin_log_detailed", "builtin_log_oneline", "builtin_op_log_comfortable", "builtin_op_log_compact"?
For 1, jj config list --include-defaults template-aliases
might be somewhat useful.
Incidentally I've implemented a variant of 2
Wow, nice! I was checking jj log -T
without passing any value but didn't bother to check with partial or wrong template name.
Is it a valuable addition if jj
would list templates in the error?
% jj log -T
error: a value is required for '--template <TEMPLATE>' but none was supplied
For more information, try '--help'.
I'd like to look into implementing that.
For 1,
jj config list --include-defaults template-aliases
might be somewhat useful.
Good suggestion, thanks! I think I'll have an alias with slight improvement for that: jj config list --include-defaults template-aliases | awk -F= '{ print($1) }' | awk -F. '{ print($2) }'
Is it a valuable addition if
jj
would list templates in the error?% jj log -T error: a value is required for '--template <TEMPLATE>' but none was supplied For more information, try '--help'.
I'd like to look into implementing that.
Yeah, but it's a bit trickier to implement because the error is detected earlier by clap. Maybe we can adjust the error message to mention -T builtin
.
Closed by #3200