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 #497

Open
dmikov opened this issue Oct 30, 2017 · 5 comments
Open

Cannot use 2 verbs at the same time #497

dmikov opened this issue Oct 30, 2017 · 5 comments

Comments

@dmikov
Copy link

dmikov commented Oct 30, 2017

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.

@nemec
Copy link
Collaborator

nemec commented Oct 31, 2017

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.

@dmikov
Copy link
Author

dmikov commented Oct 31, 2017

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?

@nemec
Copy link
Collaborator

nemec commented Oct 31, 2017

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.

@dmikov
Copy link
Author

dmikov commented Oct 31, 2017

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.

@nemec
Copy link
Collaborator

nemec commented Oct 31, 2017

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

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