aboutsummaryrefslogtreecommitdiffstats
path: root/becommands/target.py
diff options
context:
space:
mode:
Diffstat (limited to 'becommands/target.py')
-rw-r--r--becommands/target.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/becommands/target.py b/becommands/target.py
index cc67df9..b2d1ffd 100644
--- a/becommands/target.py
+++ b/becommands/target.py
@@ -28,7 +28,7 @@ def execute(args, test=False):
>>> execute(["a", "tomorrow"], test=True)
>>> execute(["a"], test=True)
tomorrow
- >>> execute(["list"], test=True)
+ >>> execute(["--list"], test=True)
tomorrow
>>> execute(["a", "none"], test=True)
>>> execute(["a"], test=True)
@@ -38,13 +38,15 @@ def execute(args, test=False):
options, args = parser.parse_args(args)
cmdutil.default_complete(options, args, parser,
bugid_args={0: lambda bug : bug.active==True})
+
if len(args) not in (1, 2):
- raise cmdutil.UsageError
+ if not (options.list == True and len(args) == 0):
+ raise cmdutil.UsageError
bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
- if len(args) == 1 and args[0] == "list":
+ if options.list:
ts = set([bd.bug_from_uuid(bug).target for bug in bd.list_uuids()])
for target in sorted(ts):
- if target and isinstance(target, str):
+ if target and isinstance(target,str):
print target
return
bug = bd.bug_from_shortname(args[0])
@@ -62,7 +64,9 @@ def execute(args, test=False):
bd.save()
def get_parser():
- parser = cmdutil.CmdOptionParser("be target BUG-ID [TARGET]")
+ parser = cmdutil.CmdOptionParser("be target BUG-ID [TARGET]\nor: be target --list")
+ parser.add_option("-l", "--list", action="store_true", dest="list",
+ help="List all available targets and exit")
return parser
longhelp="""
@@ -76,7 +80,10 @@ milestone names or release numbers.
The value "none" can be used to unset the target.
-"list" can be used in place of a bug-ID to show all existing targets.
+In the alternative `be target --list` form print a list of all
+currently specified targets. Note that bug status
+(i.e. opened/closed) is ignored. If you want to list all bugs
+matching a current target, see `be list --target TARGET'.
"""
def help():