aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--becommands/severity.py27
-rw-r--r--becommands/status.py31
-rw-r--r--libbe/cmdutil.py2
3 files changed, 53 insertions, 7 deletions
diff --git a/becommands/severity.py b/becommands/severity.py
index c44d8ed..5d27222 100644
--- a/becommands/severity.py
+++ b/becommands/severity.py
@@ -34,8 +34,7 @@ def execute(args, test=False):
"""
parser = get_parser()
options, args = parser.parse_args(args)
- cmdutil.default_complete(options, args, parser,
- bugid_args={0: lambda bug : bug.active==True})
+ complete(options, args, parser)
if len(args) not in (1,2):
raise cmdutil.UsageError
bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
@@ -75,3 +74,27 @@ Severity levels are:
longhelp.append(s)
longhelp = ''.join(longhelp)
return get_parser().help_str() + longhelp
+
+def complete(options, args, parser):
+ for option,value in cmdutil.option_value_pairs(options, parser):
+ if value == "--complete":
+ # no argument-options at the moment, so this is future-proofing
+ raise cmdutil.GetCompletions()
+ for pos,value in enumerate(args):
+ if value == "--complete":
+ try: # See if there are any per-tree severity configurations
+ bd = bugdir.BugDir(from_disk=True,
+ manipulate_encodings=False)
+ except bugdir.NoBugDir:
+ bd = None
+ if pos == 0: # fist positional argument is a bug id
+ ids = []
+ if bd != None:
+ bd.load_all_bugs()
+ filter = lambda bg : bg.active==True
+ bugs = [bg for bg in bd if filter(bg)==True]
+ ids = [bd.bug_shortname(bg) for bg in bugs]
+ raise cmdutil.GetCompletions(ids)
+ elif pos == 1: # second positional argument is a severity
+ raise cmdutil.GetCompletions(bug.severity_values)
+ raise cmdutil.GetCompletions()
diff --git a/becommands/status.py b/becommands/status.py
index b781a2a..40e9b51 100644
--- a/becommands/status.py
+++ b/becommands/status.py
@@ -34,8 +34,7 @@ def execute(args, test=False):
"""
parser = get_parser()
options, args = parser.parse_args(args)
- cmdutil.default_complete(options, args, parser,
- bugid_args={0: lambda bug : True})
+ complete(options, args, parser)
if len(args) not in (1,2):
raise cmdutil.UsageError
bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
@@ -58,12 +57,12 @@ def get_parser():
def help():
longhelp=["""
-Show or change a bug's severity level.
+Show or change a bug's status.
-If no severity is specified, the current value is printed. If a severity level
+If no status is specified, the current value is printed. If a status
is specified, it will be assigned to the bug.
-Severity levels are:
+Status levels are:
"""]
try: # See if there are any per-tree status configurations
bd = bugdir.BugDir(from_disk=True, manipulate_encodings=False)
@@ -76,3 +75,25 @@ Severity levels are:
longhelp.append(s)
longhelp = ''.join(longhelp)
return get_parser().help_str() + longhelp
+
+def complete(options, args, parser):
+ for option,value in cmdutil.option_value_pairs(options, parser):
+ if value == "--complete":
+ # no argument-options at the moment, so this is future-proofing
+ raise cmdutil.GetCompletions()
+ for pos,value in enumerate(args):
+ if value == "--complete":
+ try: # See if there are any per-tree status configurations
+ bd = bugdir.BugDir(from_disk=True,
+ manipulate_encodings=False)
+ except bugdir.NoBugDir:
+ bd = None
+ if pos == 0: # fist positional argument is a bug id
+ ids = []
+ if bd != None:
+ bd.load_all_bugs()
+ ids = [bd.bug_shortname(bg) for bg in bd]
+ raise cmdutil.GetCompletions(ids)
+ elif pos == 1: # second positional argument is a status
+ raise cmdutil.GetCompletions(bug.status_values)
+ raise cmdutil.GetCompletions()
diff --git a/libbe/cmdutil.py b/libbe/cmdutil.py
index eefed58..6be7540 100644
--- a/libbe/cmdutil.py
+++ b/libbe/cmdutil.py
@@ -97,11 +97,13 @@ def raise_get_help(option, opt, value, parser):
raise GetHelp
def raise_get_completions(option, opt, value, parser):
+ print "got completion arg"
raise GetCompletions(completions(sys.argv[1]))
class CmdOptionParser(optparse.OptionParser):
def __init__(self, usage):
optparse.OptionParser.__init__(self, usage)
+ self.disable_interspersed_args()
self.remove_option("-h")
self.add_option("-h", "--help", action="callback",
callback=raise_get_help, help="Print a help message")