cloup icon indicating copy to clipboard operation
cloup copied to clipboard

Styling metavars, default values, env var, choices...

Open janluke opened this issue 4 years ago • 1 comments

This feature can be implemented in multiple PRs but it's likely that the required changes for styling one of the elements will make easy to style the others. In that case, a single PR will probably be enough.

  • [ ] metavars (including choices)
  • [ ] default values
  • [ ] environmnent variables.

Originally proposed in #95. Closed that one because it proposes a specific regex-based approach that I think it's not suitable for Cloup. This issue is for discussing different approaches, just in case anyone would like to.

Questions:

  • is the needed work worth it or the current theming is good enough?
  • given that, in theory, Click will have a new formatting system soon or later, is this the right time to implement this feature?
  • wouldn't be better to change approach completely and show a web page when the user type --help and there's a browser available (similarly to git)? Command line will never be more readable :)

janluke avatar Oct 09 '21 11:10 janluke

@janluke In Click 8.2.0, I added the get_help_extra() method that is returning all fragments used to produce the extra part at the end of an option description in the help screen.

This means now you intercept this to individually style the environment variable, the default, the range and the required attribute like:

  • [default: None]
  • [default: (unlimited)]
  • [env var: COLOR_CLI8_TIME; default: no-time]
  • and a variety of other formats.

See:

  • https://github.com/pallets/click/issues/2516
  • https://github.com/pallets/click/pull/2517

kdeldycke avatar Aug 23 '25 11:08 kdeldycke