From 216e39db0bd3491ee3740f69a8f2afd49f76eb2f Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 27 Nov 2008 10:16:18 -0500 Subject: Command completion simplified and working for list, dummies for other cmds. All the other commands currently use default_complete(), which has no effect other than catching the --complete option and effectively aborting execution. This closes 8e1bbda4-35b6-4579-849d-117b1596ee99 --- becommands/list.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'becommands/list.py') diff --git a/becommands/list.py b/becommands/list.py index 25e72d3..ff340e3 100644 --- a/becommands/list.py +++ b/becommands/list.py @@ -34,16 +34,7 @@ def execute(args, test=False): """ parser = get_parser() options, args = parser.parse_args(args) - - for option in [o.dest for o in parser.option_list if o.dest != None]: - value = getattr(options, option) - if value == "--complete": - if option == "status": - raise cmdutil.GetCompletions(status_values) - raise cmdutil.GetCompletions() - if "--complete" in args: - raise cmdutil.GetCompletions() # no completions for arguments yet - + complete(options, args, parser) if len(args) > 0: raise cmdutil.UsageError("Too many arguments.") @@ -203,3 +194,14 @@ The boolean options are ignored if the matching string option is used. def help(): return get_parser().help_str() + longhelp + +def complete(options, args, parser): + for option, value in cmdutil.option_value_pairs(options, parser): + if value == "--complete": + if option == "status": + raise cmdutil.GetCompletions(status_values) + elif option == "severity": + raise cmdutil.GetCompletions(severity_values) + raise cmdutil.GetCompletions() + if "--complete" in args: + raise cmdutil.GetCompletions() # no positional arguments for list -- cgit