FluentArgs
FluentArgs copied to clipboard
Readme - how to reuse more complex argument builders
Hello, I really appreciate your library, it's great.
I miss in your documentation one thing - how to reuse more complex arguments in order not to reuse code. Perhaps this may be because of call builder chain and complex genericness. C# is not my strength, but I'm getting there.
My builder:
var builder = FluentArgsBuilder.New()
.Parameter<string>("-wallet").IsOptional()
.PositionalArgument<BuySell>()
.WithParser((v) => Enum.Parse<BuySell>(v, true))
.IsRequired()
.Call(direction => amount =>
{
...
}).Build();
As you see the BuySell enum builder is a "little" complex. Some other arguments will get even more complex.
Would you share your knowledge: how to refactor this code to be as follows:
var builder = FluentArgsBuilder.New()
.Parameter<string>("-wallet").IsOptional()
.BuySellPositionalArgument()
.Call(direction => amount =>
{
...
}).Build();
Bonus point - the same for non-positional argument.s