python - Defining common options for sub-commands with plac -
my question follow-up this question. shows how can use plac
automatically generate command-line interface sub-commands representing each function.
is possible tell plac
options common sub-commands, , viewed 'global' options? in fact, these options should have meaning without sub-command.
as example, might have svn checkout
, svn update
sub-commands, svn -v
or svn --version
command.
a couple of years ago set multiprocessing script using plac
. had multiple commands overlapping sets of arguments. i'll try abstract did
class interface(object): commands = ['fn1','fn2',...] dict1 = dict(quiet=(...), dryrun=(...), ...) dict2 = dict() dict3 = dict() dict1.update(dict2) @plac.annotations(**dict1) def fn1(self, dryrun, quiet, ...) ... @plac.annotations(foo=(...), **dict2) def fn2(self, foo, ...) ... @plac.annotations(**dict2) def fn3(self, ...) ...
so while arguments each function had spelled out in full, annotations built mix , matching various dictionaries.
Comments
Post a Comment