aboutsummaryrefslogtreecommitdiffstats
path: root/becommands
diff options
context:
space:
mode:
Diffstat (limited to 'becommands')
-rw-r--r--becommands/comment.py4
-rw-r--r--becommands/list.py22
-rw-r--r--becommands/set.py7
-rw-r--r--becommands/show.py5
4 files changed, 26 insertions, 12 deletions
diff --git a/becommands/comment.py b/becommands/comment.py
index 29e9f88..f7459dd 100644
--- a/becommands/comment.py
+++ b/becommands/comment.py
@@ -102,10 +102,14 @@ def execute(args, test=False):
body+='\n'
comment = parent.new_reply(body=body)
+ if options.content_type != None:
+ comment.content_type = options.content_type
bd.save()
def get_parser():
parser = cmdutil.CmdOptionParser("be comment ID [COMMENT]")
+ parser.add_option("-c", "--content-type", metavar="MIME", dest="content_type",
+ help="Set comment content-type (e.g. text/plain)", default=None)
return parser
longhelp="""
diff --git a/becommands/list.py b/becommands/list.py
index 9f4e037..1f06569 100644
--- a/becommands/list.py
+++ b/becommands/list.py
@@ -19,6 +19,10 @@ from libbe import cmdutil, bugdir, bug
import os
__desc__ = __doc__
+# get a list of * for cmp_*() comparing two bugs.
+AVAILABLE_CMPS = [fn[4:] for fn in dir(bug) if fn[:4] == 'cmp_']
+AVAILABLE_CMPS.remove("attr") # a cmp_* template.
+
def execute(args, test=False):
"""
>>> import os
@@ -35,6 +39,13 @@ def execute(args, test=False):
complete(options, args, parser)
if len(args) > 0:
raise cmdutil.UsageError("Too many arguments.")
+ cmp_list = []
+ if options.sort_by != None:
+ for cmp in options.sort_by.split(','):
+ if cmp not in AVAILABLE_CMPS:
+ raise cmdutil.UserError("Invalid sort on '%s'.\nValid sorts:\n %s"
+ % (cmp, '\n '.join(AVAILABLE_CMPS)))
+ cmp_list.append(eval('bug.cmp_%s' % cmp))
bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
bd.load_all_bugs()
@@ -115,7 +126,6 @@ def execute(args, test=False):
print "No matching bugs found"
def list_bugs(cur_bugs, title=None, just_uuids=False, xml=False):
- cur_bugs.sort(bug.cmp_full)
if xml == True:
print "<bugs>"
if len(cur_bugs) > 0:
@@ -130,7 +140,13 @@ def execute(args, test=False):
print bg.string(shortlist=True)
if xml == True:
print "</bugs>"
-
+
+ # sort bugs
+ cmp_list.extend(bug.DEFAULT_CMP_FULL_CMP_LIST)
+ cmp_fn = bug.BugCompoundComparator(cmp_list=cmp_list)
+ bugs.sort(cmp_fn)
+
+ # print list of bugs
list_bugs(bugs, just_uuids=options.uuids, xml=options.xml)
def get_parser():
@@ -143,6 +159,8 @@ 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)
+ parser.add_option("-S", "--sort", metavar="SORT-BY", dest="sort_by",
+ help="Adjust bug-sort criteria with comma-separated list SORT-BY. e.g. \"--sort creator,time\". Available criteria: %s" % ','.join(AVAILABLE_CMPS), default=None)
# boolean options. All but uuids and xml are special cases of long forms
bools = (("u", "uuids", "Only print the bug UUIDS"),
("w", "wishlist", "List bugs with 'wishlist' severity"),
diff --git a/becommands/set.py b/becommands/set.py
index b8a125e..c8bbe4f 100644
--- a/becommands/set.py
+++ b/becommands/set.py
@@ -63,12 +63,7 @@ def execute(args, test=False):
msg += '\n '.join(bd.settings_properties)
raise cmdutil.UserError(msg)
old_setting = bd.settings.get(args[0])
- try:
- setattr(bd, args[0], args[1])
- except bugdir.InvalidValue, e:
- bd.settings[args[0]] = old_setting
- bd.save()
- raise cmdutil.UserError(e)
+ setattr(bd, args[0], args[1])
else:
del bd.settings[args[0]]
bd.save()
diff --git a/becommands/show.py b/becommands/show.py
index 4b0078f..b33a96b 100644
--- a/becommands/show.py
+++ b/becommands/show.py
@@ -41,10 +41,7 @@ def execute(args, test=False):
<short-name>a</short-name>
<severity>minor</severity>
<status>open</status>
- <assigned><class 'libbe.settings_object.EMPTY'></assigned>
- <target><class 'libbe.settings_object.EMPTY'></target>
- <reporter><class 'libbe.settings_object.EMPTY'></reporter>
- <creator>John Doe <jdoe@example.com></creator>
+ <creator>John Doe &lt;jdoe@example.com&gt;</creator>
<created>...</created>
<summary>Bug A</summary>
</bug>