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

Document complex object binding #651

Open
cmeyertons opened this issue Oct 2, 2019 · 3 comments
Open

Document complex object binding #651

cmeyertons opened this issue Oct 2, 2019 · 3 comments
Labels
Area-Documentation question Further information is requested

Comments

@cmeyertons
Copy link

I've been creating all of my handlers according to the documentation like this:

command.Handler = CommandHandler.Create((IEnumerable<string> include, int count) =>
            {
                var request = new SchemaRollbackRequest(include, count);

                var svc = Container.ResolveService<ISchemaService>();

                svc.RollbackSchema(request);
            });

and it's a huge pain to update the args for every new option (requires multiple updates).

i just started creating a new command that required more than 7 options and stumbled across #458 where it's discussed to bind to a complex object, which fits my use case perfectly.

can documentation be added around the complex object binding?

@jonsequitur
Copy link
Contributor

Though it's not proper documentation, the interactive tutorial covers this to some extent: https://github.com/dotnet/command-line-api#interactive-tutorials

@jonsequitur jonsequitur added Area-Documentation question Further information is requested labels Oct 2, 2019
@dashesy
Copy link

dashesy commented Dec 10, 2019

I am not sure how that tutorial is related to creating a complex object from more than 7 options. Is there a way to parse more than 7 options using concepts like Option and TryConvertArgument?

As soon as the lamda has more than 7 options we get this:

Cannot convert lambda expression to type 'Delegate' because it is not a delegate type.


Actually, I found this and this example. So binding is by name.

@lucjanl
Copy link

lucjanl commented Jul 21, 2020

+1

This feature is a bit "hidden" and the code isn't enough documented. Personally I struggled several hours to find out how to do it before I found the #458

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Documentation question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants