Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
zummenix opened this issue Mar 1, 2024 · 5 comments
Closed

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

zummenix opened this issue Mar 1, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@zummenix
Copy link
Contributor

zummenix commented Mar 1, 2024

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

--

@necauqua
Copy link
Contributor

necauqua commented Mar 1, 2024

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

@PhilipMetzger PhilipMetzger added the enhancement New feature or request label Mar 1, 2024
@yuja
Copy link
Contributor

yuja commented Mar 2, 2024

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.

@zummenix
Copy link
Contributor Author

zummenix commented Mar 2, 2024

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

@yuja
Copy link
Contributor

yuja commented Mar 2, 2024

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.

@zummenix
Copy link
Contributor Author

zummenix commented Mar 6, 2024

Closed by #3200

@zummenix zummenix closed this as completed Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants