aboutsummaryrefslogtreecommitdiffstats
path: root/becommands/list.py
diff options
context:
space:
mode:
Diffstat (limited to 'becommands/list.py')
-rw-r--r--becommands/list.py88
1 files changed, 56 insertions, 32 deletions
diff --git a/becommands/list.py b/becommands/list.py
index 63e1cd6..8c69eaa 100644
--- a/becommands/list.py
+++ b/becommands/list.py
@@ -15,39 +15,39 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""List bugs"""
-from libbe import cmdutil, bugdir
-from libbe.bug import cmp_full, severity_values, status_values, \
- active_status_values, inactive_status_values
+from libbe import cmdutil, bugdir, bug
import os
__desc__ = __doc__
-def execute(args):
+def execute(args, test=False):
"""
>>> import os
>>> bd = bugdir.simple_bug_dir()
>>> os.chdir(bd.root)
- >>> execute([])
+ >>> execute([], test=True)
a:om: Bug A
- >>> execute(["--status", "all"])
+ >>> execute(["--status", "all"], test=True)
a:om: Bug A
b:cm: Bug B
"""
- options, args = get_parser().parse_args(args)
+ parser = get_parser()
+ options, args = parser.parse_args(args)
+ complete(options, args, parser)
if len(args) > 0:
- help()
- raise cmdutil.UserError("Too many arguments.")
- bd = bugdir.BugDir(from_disk=True)
+ raise cmdutil.UsageError("Too many arguments.")
+
+ bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
bd.load_all_bugs()
# select status
if options.status != None:
if options.status == "all":
- status = status_values
+ status = bug.status_values
else:
status = options.status.split(',')
else:
status = []
if options.active == True:
- status.extend(list(active_status_values))
+ status.extend(list(bug.active_status_values))
if options.unconfirmed == True:
status.append("unconfirmed")
if options.open == True:
@@ -55,11 +55,11 @@ def execute(args):
if options.test == True:
status.append("test")
if status == []: # set the default value
- status = active_status_values
+ status = bug.active_status_values
# select severity
if options.severity != None:
if options.severity == "all":
- severity = severity_values
+ severity = bug.severity_values
else:
severity = options.severity.split(',')
else:
@@ -67,10 +67,10 @@ def execute(args):
if options.wishlist == True:
severity.extend("wishlist")
if options.important == True:
- serious = severity_values.index("serious")
- severity.append(list(severity_values[serious:]))
+ serious = bug.severity_values.index("serious")
+ severity.append(list(bug.severity_values[serious:]))
if severity == []: # set the default value
- severity = severity_values
+ severity = bug.severity_values
# select assigned
if options.assigned != None:
if options.assigned == "all":
@@ -114,15 +114,18 @@ def execute(args):
if len(bugs) == 0:
print "No matching bugs found"
- def list_bugs(cur_bugs, title=None, no_target=False):
- cur_bugs.sort(cmp_full)
+ def list_bugs(cur_bugs, title=None, just_uuids=False):
+ cur_bugs.sort(bug.cmp_full)
if len(cur_bugs) > 0:
if title != None:
print cmdutil.underlined(title)
- for bug in cur_bugs:
- print bug.string(shortlist=True)
+ for bg in cur_bugs:
+ if just_uuids:
+ print bg.uuid
+ else:
+ print bg.string(shortlist=True)
- list_bugs(bugs, no_target=False)
+ list_bugs(bugs, just_uuids=options.uuids)
def get_parser():
parser = cmdutil.CmdOptionParser("be list [options]")
@@ -134,11 +137,12 @@ def get_parser():
help="List options matching ASSIGNED", default=None)
parser.add_option("-t", "--target", metavar="TARGET", dest="target",
help="List options matching TARGET", default=None)
- # boolean shortucts. All of these are special cases of long forms
- bools = (("w", "wishlist", "List bugs with 'wishlist' severity"),
+ # boolean options. All but uuids are special cases of long forms
+ bools = (("u", "uuids", "Only print the bug UUIDS"),
+ ("w", "wishlist", "List bugs with 'wishlist' severity"),
("i", "important", "List bugs with >= 'serious' severity"),
("A", "active", "List all active bugs"),
- ("u", "unconfirmed", "List unconfirmed bugs"),
+ ("U", "unconfirmed", "List unconfirmed bugs"),
("o", "open", "List open bugs"),
("T", "test", "List bugs in testing"),
("m", "mine", "List bugs assigned to you"),
@@ -152,9 +156,20 @@ def get_parser():
dest=attr, help=help)
return parser
-longhelp="""
-This command lists bugs. There are several criteria that you can
-search by:
+
+def help():
+ longhelp="""
+This command lists bugs. Normally it prints a short string like
+ 576:om: Allow attachments
+Where
+ 576 the bug id
+ o the bug status is 'open' (first letter)
+ m the bug severity is 'minor' (first letter)
+ Allo... the bug summary string
+
+You can optionally (-u) print only the bug ids.
+
+There are several criteria that you can filter by:
* status
* severity
* assigned (who the bug is assigned to)
@@ -174,8 +189,17 @@ target
In addition, there are some shortcut options that set boolean flags.
The boolean options are ignored if the matching string option is used.
-""" % (','.join(status_values),
- ','.join(severity_values))
-
-def help():
+""" % (','.join(bug.status_values),
+ ','.join(bug.severity_values))
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(bug.status_values)
+ elif option == "severity":
+ raise cmdutil.GetCompletions(bug.severity_values)
+ raise cmdutil.GetCompletions()
+ if "--complete" in args:
+ raise cmdutil.GetCompletions() # no positional arguments for list