commandline icon indicating copy to clipboard operation
commandline copied to clipboard

Default value callback

Open absolutejam opened this issue 3 years ago • 2 comments

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!

absolutejam avatar Mar 31 '21 09:03 absolutejam

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

johnjaylward avatar Apr 15 '21 22:04 johnjaylward

Thanks, I'll take a look at this and see if it does the trick!

absolutejam avatar May 17 '21 09:05 absolutejam