I am reading the CommandLineParser documentation and I am very interested in the way functionality is designed here:
I basically have a command line application where I need to set different parameters. Something like below
MyApp.exe -a val1 -b val2 -c -d
What I am trying to achieve is that if -c is present in the command line application, I want to take the result of what -a val1 -b val2 produced and then call my next function with that result and the operation that -c does.
In this case:
int Main(string[] args) {
return CommandLine.Parser.Default.ParseArguments<AddOptions, CommitOptions, CloneOptions>(args)
.MapResult(
(AddOptions opts) => RunAddAndReturnExitCode(opts),
(CommitOptions opts) => RunCommitAndReturnExitCode(opts),
errs => 1);
}
How can I get the result of RunAddAndReturnExitCode(opts) and add it into RunCommitAndReturnExitCode?
I really like how the verbs are designed since it keeps the code nice and clean.