Skip to content

Introduce more than 7 arguments in System.CommandLine.Invocation.CommandHandler.Create #983

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

Closed
mristin opened this issue Jul 21, 2020 · 6 comments · Fixed by #988
Closed

Comments

@mristin
Copy link
Contributor

mristin commented Jul 21, 2020

Hi,
I noticed that the CommandHandler.Create is limited to at most 7 arguments of the action. This corresponds to at most 7 options, which is a bit too little in a more complex applications.

Was there a reason for this limit (instead of pushing it higher to, say, 16)? What is your suggested way to handle more than 7 options?

Thanks a lot for the answers in advance! Please let me know if I should create a pull request to introduce a higher limit if there is no particular reason for the current one.

@spmyob
Copy link

spmyob commented Jul 23, 2020

I've run into this exact same issue and would be interested in finding out if there's a workaround for this.

@jonsequitur
Copy link
Contributor

The model binder also supports binding to complex types. You can see more details here: https://github.com/dotnet/command-line-api/blob/master/docs/model-binding.md#more-complex-types

@spmyob
Copy link

spmyob commented Jul 23, 2020

That looks exactly like what I needed. Not sure how I missed it in the docs. Thanks @jonsequitur.

@mristin
Copy link
Contributor Author

mristin commented Jul 23, 2020

@jonsequitur shouldn't that article be referenced from the home page? I also missed it, especially since the referenced article "Argument validation and binding" does not make a visible reference to complex type binding.

(Should I make a PR for the homepage or extend the article "Argument ..."?)

@mristin
Copy link
Contributor Author

mristin commented Jul 23, 2020

@jonsequitur it still wouldn't harm to add more arguments to Create or you'd prefer not to?

@jonsequitur
Copy link
Contributor

it still wouldn't harm to add more arguments to Create or you'd prefer not to?

I mean, we could go to 11... Do you have a preference for more arguments versus complex model binding?

The documentation could use some help though. We've just started trying to consolidate and reorganize the docs, and we want to make a push to add XML comments as well. PRs are more than welcome.

jonsequitur pushed a commit that referenced this issue Jul 25, 2020
* Refer to complex binding in howto

This patch adds a reference in "How-to" page to point the readers to the
relevant section about how to bind the more complex types. Since "Model
binding" page is not directly referenced from the Readme, many readers
are not aware of it.

This is related to issue #983.
jonsequitur pushed a commit that referenced this issue Aug 27, 2020
This patch fixes `System.CommandLine.Invocation.CommandHandler.Create`
so that it can handle actions with up to 11 arguments. Current limit of
7 arguments is not enough for a more complex applications.

While users can alternatively bind arguments to arbitrary number of
properties, this requires refactoring the code once the limit is
hit. Additionally, some users are not aware of the feature and could
hit the wall unintentionally. With this patch, the arbitrary, but
reasonable limit of 11 arguments should cover most of the use cases
"in the wild".

Fix #983.
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

Successfully merging a pull request may close this issue.

3 participants