-
Notifications
You must be signed in to change notification settings - Fork 123
Closed
Labels
Description
example/tab_autocomp_dynamic.py disapear from git for some reason.
Could you please add simple example of dynamic autocomplete ?
I just need to filter choice of second argument based on the first one
class STGP_Cmd(cmd2.Cmd):
def __init__(self, *args, **kwargs):
self.a = {'a': ['ab', 'ac', 'ad'], 'b': ['bb', 'bc', 'bd']}
def get_groups(self):
return self.a.keys()
def get_params(self, group):
return self.a[group]
get_param_parser = argparse.ArgumentParser()
get_param_parser.add_argument('group', choices_method=get_groups)
get_param_parser.add_argument('param', choices_method=get_params)
@cmd2.with_argparser(get_param_parser)
def do_get_param(self, args):
self.poutput(self.get_param(args.param, args.group))