jj icon indicating copy to clipboard operation
jj copied to clipboard

FR: A way to discover names of builtin and user defined templates

Open zummenix opened this issue 11 months ago • 4 comments

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:

  1. a dedicated jj command to print available templates. Cons: too many commands already.
  2. 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.
  3. list templates in jj log --help under the -T argument (Does clap 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

--

zummenix avatar Mar 01 '24 19:03 zummenix

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

necauqua avatar Mar 01 '24 19:03 necauqua

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.

yuja avatar Mar 02 '24 01:03 yuja

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) }'

zummenix avatar Mar 02 '24 04:03 zummenix

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.

yuja avatar Mar 02 '24 05:03 yuja

Closed by #3200

zummenix avatar Mar 06 '24 03:03 zummenix