Cannot use 2 verbs at the same time
dmikov opened this issue · 5 comments
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.
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.
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?
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.
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.
What python library are you using to get that feature? I really only have experience with argparse..