commandline
commandline copied to clipboard
Default value callback
Howdy!
I'm just evaluating this library for a couple of F# projects, and I was wondering if there's any way to provide a function (or Action<_>
) as the default instead of a static value. This would allow me to pull in values from elsewhere, namely IConfiguration
so that I get I get config file & env values as the fallback too.
Is anything like this currently possible?
Cheers!
I'm not familiar with f# syntax, but this is what I do in c# to provide default values:
ParserResult<Options> parserResult = Parser.Default.ParseArguments(Options.FromAppSettings, args);
The first parameter there is a method reference. My method pulls values of out an app/web.config file (.NET Framework). The parser then uses those values as defaults, and the command line parser will override them if provided by args
Thanks, I'll take a look at this and see if it does the trick!