Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readme - how to reuse more complex argument builders #44

Open
chris-rutkowski opened this issue Jul 14, 2021 · 0 comments
Open

Readme - how to reuse more complex argument builders #44

chris-rutkowski opened this issue Jul 14, 2021 · 0 comments

Comments

@chris-rutkowski
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant