Open BobSilent opened 3 years ago
Do you want help to show, as the default, a value potentially coming from a different configuration provider? In other words, by "fallback" do you mean the application-defined default that would be used in the absence of any user-created configurations?
yes exactly, i updated my question with an example of the AaaCommandOptions
class, you see i set some defaults in the class when it gets created
I want to show these default values in the commandline help
We've made some changes recently to allow the HelpBuilder
to be more customizable for when you want to communicate this kind of detail to your users. Here's an example:
https://github.com/dotnet/command-line-api/blob/d4d31f7291da5e06b573bf5f3096542b02fe5553/src/System.CommandLine.Tests/UseHelpTests.cs#L216-L237
This looks helpful, but in my case I want to provide a default Customization although I cannot provide an DefaultValue Function.
https://github.com/dotnet/command-line-api/blob/d4d31f7291da5e06b573bf5f3096542b02fe5553/src/System.CommandLine/Help/HelpBuilder.cs#L445-L456
the customization gets only applied if it has a default value: it checks for .HasDefaultValue
.
@jonsequitur is it really required to check if a default value exists, or in case of Customization it can be applied anyway, as this is what I want, if I explicitly specify a customization.
The idea would be to completely replace the description for the argument so that you could include whatever description of the defaults and configurations are appropriate.
yes, more or less like that.
So for me it would be sufficient to replace the .HasDefaultValue
to something like HasDefaultValueOrCustomization
I am using commandline in hosting and binding the configuration values, from a json configuration file and some values from commandline - multiple configuration providers.
I have a Configuration:
and i am Binding the values like that:
What I want to achieve is: having a possibility to describe a default (fall back value) which can be overwritten in either the config file (via environment variable) or at latest via commandline (if a option exists)
What i also want to have is to show the default value in the command line help.
If i use the
Func<T> getDefaultValue
:This shows nicely the default value in the help output, but it also sets the value if the option is not provided on command line. So the Fallback value is always set if no other value is provided via command line.
As workaround I am doing today something like that
What would be a recommended way?