-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Specify default text for optional arguments in help #1695
Comments
I actually removed the colorizing for default values in #1824. I wanted to rethink quite a bit on how to display all kinds of things like these. But, it's for v3.1 |
One proposal for #2389 includes exposing some level of styling to the user. #3008 explores pulling defaulting logic out of the core of clap into helpers that you can pass into Since both of these are not solid enough as alternatives yet, still keeping this open to ensure the use case gets covered by something |
It sounds like there's interest for this, so I might prepare a PR. Related issues:
|
Describe your use case
Often, the default values of arguments are determined based on runtime computation, e.g. a
--threads
parameter defaulting to the number of available threads on the system, or a--config
option defaulting to an OS-specific path in the user's home directory (e.g.$XDG_CONFIG_HOME/app-name/config.ron
on Linux). It's beneficial for usability to be able to summarize the default arguments, e.g.Number of threads to use [default: # of threads on system]
orPath to configuration [default: $XDG_CONFIG_HOME/app-name/config.ron]
.At present, there's no API to give a (purely cosmetic) default option text for an optional argument.
Currently, I just do:
but this isn't quite correct (e.g. it doesn't format the default with
Colorizer::good
).Arguably this is an X-Y problem and the real feature request is for "computed defaults" (related to #1694), but I think even with such a mechanism there's value in being able to summarize the default path (rather than e.g. inlining volatile variables like
$XDG_RUNTIME_DIR
in the help text).Describe the solution you'd like
The text was updated successfully, but these errors were encountered: