On Mon, Aug 24, 2009 at 02:29:54PM +0200, Michael Hanselmann wrote: > 2009/8/24 Iustin Pop <[email protected]>: > > On Mon, Aug 24, 2009 at 11:56:34AM +0200, Michael Hanselmann wrote: > >> --- a/lib/cli.py > >> +++ b/lib/cli.py > >> -ARGS_NONE = None > >> -ARGS_ONE = ARGS_FIXED(1) > >> -ARGS_ANY = ARGS_ATLEAST(0) > > > > Please do not remove these - at least not ARGS_NONE, which should become > > [] and thus a lot of the code churn could be eliminated. > > > > As for the others, I think (looking at the changes in scripts/gnt-*) > > that having usual arguments for ARGS_INSTANCE_ONE and ARGS_NODE_ONE > > would be really helpful. > > As discussed offline this will be done in a separate patch. Merging > with the patches buildin on top of this one would be too painful > otherwise. > > >> +def _CheckArguments(cmd, args_def, args): > >> + """Verifies the arguments using the argument definition. > >> + > >> + """ > > > > Would you mind please expanding the docstring to detail the algorithm > > you use below? > > Interdiff: > --- a/lib/cli.py > +++ b/lib/cli.py > @@ -465,6 +465,24 @@ def _ParseArgs(argv, commands, aliases): > def _CheckArguments(cmd, args_def, args): > """Verifies the arguments using the argument definition. > > + Algorithm: > + > + 1. Abort with error if values specified by user but none expected. > + > + 1. For each argument in definition > + > + 1. Keep running count of minimum number of values (min_count) > + 1. Keep running count of maximum number of values (max_count) > + 1. If it has an unlimited number of values > + > + 1. Abort with error if it's not the last argument in the definition > + > + 1. If last argument has limited number of values > + > + 1. Abort with error if number of values doesn't match or is too large > + > + 1. Abort with error if user didn't pass enough values (min_count) > +
LGTM.
