aboutsummaryrefslogtreecommitdiffstats
path: root/becommands
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-07-06 15:54:13 -0400
committerW. Trevor King <wking@drexel.edu>2009-07-06 15:54:13 -0400
commitab1b33b702c4c84a90fd5d7ba8c6dd0078fc303a (patch)
tree37d05931973c5e52247dc6df5625664495505e33 /becommands
parenta536332660c8374e2000541e2db5ad6cea3b0e5e (diff)
downloadbugseverywhere-ab1b33b702c4c84a90fd5d7ba8c6dd0078fc303a.tar.gz
Added ability to show individual comments with "be show".
Diffstat (limited to 'becommands')
-rw-r--r--becommands/show.py40
1 files changed, 30 insertions, 10 deletions
diff --git a/becommands/show.py b/becommands/show.py
index ff434ab..dfaece1 100644
--- a/becommands/show.py
+++ b/becommands/show.py
@@ -53,27 +53,47 @@ 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})
+ bugid_args={-1: lambda bug : bug.active==True})
if len(args) == 0:
raise cmdutil.UsageError
bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
- for bugid in args:
- bug = bd.bug_from_shortname(bugid)
- if options.dumpXML:
- print bug.xml(show_comments=True)
+ for shortname in args:
+ if shortname.count(':') > 1:
+ raise cmdutil.UserError("Invalid id '%s'." % shortname)
+ elif shortname.count(':') == 1:
+ # Split shortname generated by Comment.comment_shortnames()
+ bugname = shortname.split(':')[0]
+ is_comment = True
else:
- print bug.string(show_comments=True)
- if bugid != args[-1]:
- print "" # add a blank line between bugs
+ bugname = shortname
+ is_comment = False
+ bug = bd.bug_from_shortname(bugname)
+ if is_comment == False:
+ if options.dumpXML:
+ print bug.xml(show_comments=True)
+ else:
+ print bug.string(show_comments=True)
+ else:
+ comment = bug.comment_root.comment_from_shortname(
+ shortname, bug_shortname=bugname)
+ if options.dumpXML:
+ print comment.xml(shortname=shortname)
+ else:
+ print comment.string(shortname=shortname)
+ if shortname != args[-1] and options.dumpXML == False:
+ print "" # add a blank line between bugs/comments
def get_parser():
- parser = cmdutil.CmdOptionParser("be show [options] BUG-ID [BUG-ID ...]")
+ parser = cmdutil.CmdOptionParser("be show [options] ID [ID ...]")
parser.add_option("-x", "--xml", action="store_true",
dest='dumpXML', help="Dump as XML")
return parser
longhelp="""
-Show all information about a bug.
+Show all information about the bugs or comments whose IDs are given.
+
+It's probably not a good idea to mix bug and comment IDs in a single
+call, but you're free to do so if you like.
"""
def help():