aboutsummaryrefslogtreecommitdiffstats
path: root/becommands
diff options
context:
space:
mode:
Diffstat (limited to 'becommands')
-rw-r--r--becommands/assign.py4
-rw-r--r--becommands/close.py4
-rw-r--r--becommands/comment.py4
-rw-r--r--becommands/diff.py4
-rw-r--r--becommands/help.py5
-rw-r--r--becommands/list.py22
-rw-r--r--becommands/merge.py4
-rw-r--r--becommands/new.py4
-rw-r--r--becommands/open.py4
-rw-r--r--becommands/remove.py4
-rw-r--r--becommands/set.py4
-rw-r--r--becommands/set_root.py4
-rw-r--r--becommands/severity.py4
-rw-r--r--becommands/show.py4
-rw-r--r--becommands/status.py4
-rw-r--r--becommands/target.py4
16 files changed, 58 insertions, 25 deletions
diff --git a/becommands/assign.py b/becommands/assign.py
index b00c5c2..9869350 100644
--- a/becommands/assign.py
+++ b/becommands/assign.py
@@ -41,7 +41,9 @@ def execute(args, test=False):
>>> bd.bug_from_shortname("a").assigned is None
True
"""
- options, args = get_parser().parse_args(args)
+ parser = get_parser()
+ options, args = parser.parse_args(args)
+ cmdutil.default_complete(options, args, parser)
assert(len(args) in (0, 1, 2))
if len(args) == 0:
raise cmdutil.UsageError("Please specify a bug id.")
diff --git a/becommands/close.py b/becommands/close.py
index d125397..37fa032 100644
--- a/becommands/close.py
+++ b/becommands/close.py
@@ -31,7 +31,9 @@ def execute(args, test=False):
>>> print bd.bug_from_shortname("a").status
closed
"""
- options, args = get_parser().parse_args(args)
+ parser = get_parser()
+ options, args = parser.parse_args(args)
+ cmdutil.default_complete(options, args, parser)
if len(args) == 0:
raise cmdutil.UsageError("Please specify a bug id.")
if len(args) > 1:
diff --git a/becommands/comment.py b/becommands/comment.py
index 4470f75..5eac102 100644
--- a/becommands/comment.py
+++ b/becommands/comment.py
@@ -55,7 +55,9 @@ def execute(args, test=False):
I like cheese
<BLANKLINE>
"""
- options, args = get_parser().parse_args(args)
+ parser = get_parser()
+ options, args = parser.parse_args(args)
+ cmdutil.default_complete(options, args, parser)
if len(args) == 0:
raise cmdutil.UsageError("Please specify a bug or comment id.")
if len(args) > 2:
diff --git a/becommands/diff.py b/becommands/diff.py
index 1696913..c090fa8 100644
--- a/becommands/diff.py
+++ b/becommands/diff.py
@@ -39,7 +39,9 @@ def execute(args, test=False):
status: open -> closed
<BLANKLINE>
"""
- options, args = get_parser().parse_args(args)
+ parser = get_parser()
+ options, args = parser.parse_args(args)
+ cmdutil.default_complete(options, args, parser)
if len(args) == 0:
revision = None
if len(args) == 1:
diff --git a/becommands/help.py b/becommands/help.py
index 1c99af5..e228eed 100644
--- a/becommands/help.py
+++ b/becommands/help.py
@@ -26,11 +26,14 @@ def execute(args):
<BLANKLINE>
Options:
-h, --help Print a help message
+ --complete Print a list of available completions
<BLANKLINE>
Print help for specified command or list of all commands.
<BLANKLINE>
"""
- options, args = get_parser().parse_args(args)
+ parser = get_parser()
+ options, args = parser.parse_args(args)
+ cmdutil.default_complete(options, args, parser)
if len(args) > 1:
raise cmdutil.UsageError("Too many arguments.")
if len(args) == 0:
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
diff --git a/becommands/merge.py b/becommands/merge.py
index d1829d6..583bd28 100644
--- a/becommands/merge.py
+++ b/becommands/merge.py
@@ -120,7 +120,9 @@ def execute(args, test=False):
>>> print b.status
closed
"""
- options, args = get_parser().parse_args(args)
+ parser = get_parser()
+ options, args = parser.parse_args(args)
+ cmdutil.default_complete(options, args, parser)
if len(args) < 2:
raise cmdutil.UsageError("Please specify two bug ids.")
if len(args) > 2:
diff --git a/becommands/new.py b/becommands/new.py
index bc17f83..58fabbc 100644
--- a/becommands/new.py
+++ b/becommands/new.py
@@ -38,7 +38,9 @@ def execute(args, test=False):
>>> bug.target == None
True
"""
- options, args = get_parser().parse_args(args)
+ parser = get_parser()
+ options, args = parser.parse_args(args)
+ cmdutil.default_complete(options, args, parser)
if len(args) != 1:
raise cmdutil.UsageError("Please supply a summary message")
bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
diff --git a/becommands/open.py b/becommands/open.py
index 9a9667d..41db5e9 100644
--- a/becommands/open.py
+++ b/becommands/open.py
@@ -30,7 +30,9 @@ def execute(args, test=False):
>>> print bd.bug_from_shortname("b").status
open
"""
- options, args = get_parser().parse_args(args)
+ parser = get_parser()
+ options, args = parser.parse_args(args)
+ cmdutil.default_complete(options, args, parser)
if len(args) == 0:
raise cmdutil.UsageError, "Please specify a bug id."
if len(args) > 1:
diff --git a/becommands/remove.py b/becommands/remove.py
index 386d9d4..cd877c5 100644
--- a/becommands/remove.py
+++ b/becommands/remove.py
@@ -35,7 +35,9 @@ def execute(args, test=False):
... print "Bug not found"
Bug not found
"""
- options, args = get_parser().parse_args(args)
+ parser = get_parser()
+ options, args = parser.parse_args(args)
+ cmdutil.default_complete(options, args, parser)
if len(args) != 1:
raise cmdutil.UsageError, "Please specify a bug id."
bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
diff --git a/becommands/set.py b/becommands/set.py
index 3904262..aef5eb3 100644
--- a/becommands/set.py
+++ b/becommands/set.py
@@ -32,7 +32,9 @@ def execute(args, test=False):
>>> execute(["target"], test=True)
None
"""
- options, args = get_parser().parse_args(args)
+ parser = get_parser()
+ options, args = parser.parse_args(args)
+ cmdutil.default_complete(options, args, parser)
if len(args) > 2:
raise cmdutil.UsageError, "Too many arguments"
bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
diff --git a/becommands/set_root.py b/becommands/set_root.py
index 11f38b9..3749e28 100644
--- a/becommands/set_root.py
+++ b/becommands/set_root.py
@@ -55,7 +55,9 @@ def execute(args, test=False):
UserError: No such directory: /highly-unlikely-to-exist
>>> os.chdir('/')
"""
- options, args = get_parser().parse_args(args)
+ parser = get_parser()
+ options, args = parser.parse_args(args)
+ cmdutil.default_complete(options, args, parser)
if len(args) > 1:
raise cmdutil.UsageError
if len(args) == 1:
diff --git a/becommands/severity.py b/becommands/severity.py
index 3c856de..29a5545 100644
--- a/becommands/severity.py
+++ b/becommands/severity.py
@@ -33,7 +33,9 @@ def execute(args, test=False):
Traceback (most recent call last):
UserError: Invalid severity level: none
"""
- options, args = get_parser().parse_args(args)
+ parser = get_parser()
+ options, args = parser.parse_args(args)
+ cmdutil.default_complete(options, args, parser)
if len(args) not in (1,2):
raise cmdutil.UsageError
bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
diff --git a/becommands/show.py b/becommands/show.py
index c58e6bb..3c00712 100644
--- a/becommands/show.py
+++ b/becommands/show.py
@@ -35,7 +35,9 @@ def execute(args, test=False):
Bug A
<BLANKLINE>
"""
- options, args = get_parser().parse_args(args)
+ parser = get_parser()
+ options, args = parser.parse_args(args)
+ cmdutil.default_complete(options, args, parser)
if len(args) == 0:
raise cmdutil.UsageError
bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
diff --git a/becommands/status.py b/becommands/status.py
index 73d43f8..4ac7170 100644
--- a/becommands/status.py
+++ b/becommands/status.py
@@ -33,7 +33,9 @@ def execute(args, test=False):
Traceback (most recent call last):
UserError: Invalid status: none
"""
- options, args = get_parser().parse_args(args)
+ parser = get_parser()
+ options, args = parser.parse_args(args)
+ cmdutil.default_complete(options, args, parser)
if len(args) not in (1,2):
raise cmdutil.UsageError
bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
diff --git a/becommands/target.py b/becommands/target.py
index 4371ef0..497ebf0 100644
--- a/becommands/target.py
+++ b/becommands/target.py
@@ -32,7 +32,9 @@ def execute(args, test=False):
>>> execute(["a"], test=True)
No target assigned.
"""
- options, args = get_parser().parse_args(args)
+ parser = get_parser()
+ options, args = parser.parse_args(args)
+ cmdutil.default_complete(options, args, parser)
if len(args) not in (1, 2):
raise cmdutil.UsageError
bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)