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

Cannot use 2 verbs at the same time #176

Open
ericnewton76 opened this issue Nov 4, 2017 · 6 comments
Open

Cannot use 2 verbs at the same time #176

ericnewton76 opened this issue Nov 4, 2017 · 6 comments

Comments

@ericnewton76
Copy link
Member

Issue by dmikov
Monday Oct 30, 2017 at 16:05 GMT
Originally opened as gsscoder/commandline#497


I have 2 verbs upgrade and validate, upgrade has 2 options v and c, the validate has 1 option f. If I use them separately it all works, if I put 2 verbs together on command line I am getting the UnknownOptionError from second verb option. i.e if the upgrade is first, then f on validate causes the error, if validate is first then v and c cause an error.

@ericnewton76
Copy link
Member Author

Comment by nemec
Tuesday Oct 31, 2017 at 17:28 GMT


What is the full text you are sending to the application? I suspect what you are trying to do is not supported - only one verb may be used at a time. The first verb you use is probably trying to read the second verb as if it were a parameter of its own.

@ericnewton76
Copy link
Member Author

Comment by dmikov
Tuesday Oct 31, 2017 at 20:40 GMT


I am sure this is the issue, does it not tokenize verbs on it's own? So now only one verb can be used? You cannot decide to mydatabaseutil clean -all upgrade -v:3 validate -strict?

@ericnewton76
Copy link
Member Author

Comment by nemec
Tuesday Oct 31, 2017 at 20:57 GMT


No it does not. The library allows "free" argument values (identified by a ValueAttribute) that are not tied to a flag like -v. For example, a verb like:

class CreateProject
{
    [Value]
    public string ProjectName { get; set; }
}

when called with util.exe createproject upgrade would be parsed as verb=CreateProject, ProjectName=upgrade. Even if you had a second verb called Upgrade, the parser would continue parsing as if the remaining arguments belonged to properties on the initial verb.

I hope that makes sense.

@ericnewton76
Copy link
Member Author

Comment by dmikov
Tuesday Oct 31, 2017 at 21:40 GMT


Of course it does. I am just accustomed to tokenizing in Python cli etc. I can see how tokenizing to verbs|options/arguments during runtime, make it hard to do precise verb names instead. I will try to write good parser with antlr that can do a list of verbs to do the right AST. Hopefully we can use it here, I really not looking forward to reinvent all attributes that is so nicely implemented here.

@ericnewton76
Copy link
Member Author

Comment by nemec
Tuesday Oct 31, 2017 at 22:03 GMT


What python library are you using to get that feature? I really only have experience with argparse..

@moh-hassan
Copy link
Collaborator

Closed for age.

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

2 participants