aboutsummaryrefslogtreecommitdiffstats
path: root/becommands
diff options
context:
space:
mode:
Diffstat (limited to 'becommands')
-rw-r--r--becommands/assign.py19
-rw-r--r--becommands/close.py18
-rw-r--r--becommands/comment.py16
-rw-r--r--becommands/help.py46
-rw-r--r--becommands/inprogress.py18
-rw-r--r--becommands/new.py4
-rw-r--r--becommands/open.py18
-rw-r--r--becommands/set.py20
-rw-r--r--becommands/severity.py19
-rw-r--r--becommands/show.py27
-rw-r--r--becommands/target.py21
-rw-r--r--becommands/upgrade.py11
12 files changed, 185 insertions, 52 deletions
diff --git a/becommands/assign.py b/becommands/assign.py
index d682130..d7c2fca 100644
--- a/becommands/assign.py
+++ b/becommands/assign.py
@@ -26,17 +26,18 @@ def execute(args):
>>> os.chdir(dir.dir)
>>> dir.get_bug("a").assigned is None
True
- >>> execute(("a",))
+ >>> execute(["a",])
>>> dir.get_bug("a").assigned == names.creator()
True
- >>> execute(("a", "someone"))
+ >>> execute(["a", "someone"])
>>> dir.get_bug("a").assigned
- 'someone'
- >>> execute(("a","none"))
+ u'someone'
+ >>> execute(["a","none"])
>>> dir.get_bug("a").assigned is None
True
>>> tests.clean_up()
"""
+ options, args = get_parser().parse_args(args)
assert(len(args) in (0, 1, 2))
if len(args) == 0:
print help()
@@ -51,10 +52,11 @@ def execute(args):
bug.assigned = args[1]
bug.save()
+def get_parser():
+ parser = cmdutil.CmdOptionParser("be assign bug-id [assignee]")
+ return parser
-def help():
- return """be assign bug-id [assignee]
-
+longhelp = """
Assign a person to fix a bug.
By default, the bug is self-assigned. If an assignee is specified, the bug
@@ -65,3 +67,6 @@ appears in Creator fields.
To un-assign a bug, specify "none" for the assignee.
"""
+
+def help():
+ return get_parser().help_str() + longhelp
diff --git a/becommands/close.py b/becommands/close.py
index 9d01a7f..2b28055 100644
--- a/becommands/close.py
+++ b/becommands/close.py
@@ -23,13 +23,25 @@ def execute(args):
>>> dir = tests.simple_bug_dir()
>>> os.chdir(dir.dir)
>>> dir.get_bug("a").status
- 'open'
- >>> execute(("a",))
+ u'open'
+ >>> execute(["a",])
>>> dir.get_bug("a").status
- 'closed'
+ u'closed'
>>> tests.clean_up()
"""
+ options, args = get_parser().parse_args(args)
assert(len(args) == 1)
bug = cmdutil.get_bug(args[0])
bug.status = "closed"
bug.save()
+
+def get_parser():
+ parser = cmdutil.CmdOptionParser("be close bug-id")
+ return parser
+
+longhelp="""
+Close the bug identified by bug-id.
+"""
+
+def help():
+ return get_parser().help_str() + longhelp
diff --git a/becommands/comment.py b/becommands/comment.py
index c53fd87..4f0bf3b 100644
--- a/becommands/comment.py
+++ b/becommands/comment.py
@@ -26,7 +26,7 @@ def execute(args):
>>> execute(["a", "This is a comment about a"])
>>> comment = dir.get_bug("a").list_comments()[0]
>>> comment.body
- 'This is a comment about a\\n'
+ u'This is a comment about a\\n'
>>> comment.From == names.creator()
True
>>> comment.date <= int(time.time())
@@ -40,13 +40,13 @@ def execute(args):
>>> os.environ["EDITOR"] = "echo 'I like cheese' > "
>>> execute(["b"])
>>> dir.get_bug("b").list_comments()[0].body
- 'I like cheese\\n'
+ u'I like cheese\\n'
>>> tests.clean_up()
"""
options, args = get_parser().parse_args(args)
if len(args) < 1:
raise cmdutil.UsageError()
- bug = cmdutil.get_bug(args[0])
+ bug, parent_comment = cmdutil.get_bug_and_comment(args[0])
if len(args) == 1:
try:
body = utility.editor_string()
@@ -61,15 +61,21 @@ def execute(args):
body+='\n'
comment = bugdir.new_comment(bug, body)
+ if parent_comment is not None:
+ comment.in_reply_to = parent_comment.uuid
comment.save()
def get_parser():
- parser = cmdutil.CmdOptionParser("be comment BUG-ID COMMENT")
+ parser = cmdutil.CmdOptionParser("be comment ID COMMENT")
return parser
longhelp="""
-Add a comment to a bug.
+To add a comment to a bug, use the bug ID as the argument. To reply to another
+comment, specify the comment name (as shown in "be show" output).
+
+$EDITOR is used to launch an editor. If unspecified, no comment will be
+created.)
"""
def help():
diff --git a/becommands/help.py b/becommands/help.py
new file mode 100644
index 0000000..1402a2a
--- /dev/null
+++ b/becommands/help.py
@@ -0,0 +1,46 @@
+# Copyright (C) 2006 Thomas Gerigk
+# <tgerigk@gmx.de>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+"""Print help for given subcommand"""
+from libbe import bugdir, cmdutil, names, utility
+def execute(args):
+ """
+ Print help of specified command.
+ """
+ options, args = get_parser().parse_args(args)
+ if len(args) > 1:
+ raise cmdutil.UserError("Too many arguments.")
+ if len(args) == 0:
+ print_command_list()
+ else:
+ try:
+ print cmdutil.help(args[0])
+ except AttributeError:
+ print "No help available"
+
+ return
+
+
+def get_parser():
+ parser = cmdutil.CmdOptionParser("be help [COMMAND]")
+ return parser
+
+longhelp="""
+Print help for specified command or list of all commands.
+"""
+
+def help():
+ return get_parser().help_str() + longhelp
diff --git a/becommands/inprogress.py b/becommands/inprogress.py
index 5b9f767..005bdbc 100644
--- a/becommands/inprogress.py
+++ b/becommands/inprogress.py
@@ -23,13 +23,25 @@ def execute(args):
>>> dir = tests.simple_bug_dir()
>>> os.chdir(dir.dir)
>>> dir.get_bug("a").status
- 'open'
- >>> execute(("a",))
+ u'open'
+ >>> execute(["a",])
>>> dir.get_bug("a").status
- 'in-progress'
+ u'in-progress'
>>> tests.clean_up()
"""
+ options, args = get_parser().parse_args(args)
assert(len(args) == 1)
bug = cmdutil.get_bug(args[0])
bug.status = "in-progress"
bug.save()
+
+def get_parser():
+ parser = cmdutil.CmdOptionParser("be inprogress BUG-ID")
+ return parser
+
+longhelp="""
+Mark a bug as 'in-progress'.
+"""
+
+def help():
+ return get_parser().help_str() + longhelp
diff --git a/becommands/new.py b/becommands/new.py
index f16306d..7bd2382 100644
--- a/becommands/new.py
+++ b/becommands/new.py
@@ -27,12 +27,12 @@ def execute(args):
Created bug with ID a
>>> bug = list(dir.list())[0]
>>> bug.summary
- 'this is a test'
+ u'this is a test'
>>> bug.creator = os.environ["LOGNAME"]
>>> bug.time <= int(time.time())
True
>>> bug.severity
- 'minor'
+ u'minor'
>>> bug.target == None
True
>>> tests.clean_up()
diff --git a/becommands/open.py b/becommands/open.py
index 7923091..d93eb61 100644
--- a/becommands/open.py
+++ b/becommands/open.py
@@ -23,13 +23,25 @@ def execute(args):
>>> dir = tests.simple_bug_dir()
>>> os.chdir(dir.dir)
>>> dir.get_bug("b").status
- 'closed'
- >>> execute(("b",))
+ u'closed'
+ >>> execute(["b",])
>>> dir.get_bug("b").status
- 'open'
+ u'open'
>>> tests.clean_up()
"""
+ options, args = get_parser().parse_args(args)
assert(len(args) == 1)
bug = cmdutil.get_bug(args[0])
bug.status = "open"
bug.save()
+
+def get_parser():
+ parser = cmdutil.CmdOptionParser("be open BUG-ID")
+ return parser
+
+longhelp="""
+Mark a bug as 'open'.
+"""
+
+def help():
+ return get_parser().help_str() + longhelp
diff --git a/becommands/set.py b/becommands/set.py
index 2a977ca..a93cbf3 100644
--- a/becommands/set.py
+++ b/becommands/set.py
@@ -22,16 +22,17 @@ def execute(args):
>>> import os
>>> dir = tests.simple_bug_dir()
>>> os.chdir(dir.dir)
- >>> execute(("a",))
+ >>> execute(["a",])
None
- >>> execute(("a", "tomorrow"))
- >>> execute(("a",))
+ >>> execute(["a", "tomorrow"])
+ >>> execute(["a",])
tomorrow
- >>> execute(("a", "none"))
- >>> execute(("a",))
+ >>> execute(["a", "none"])
+ >>> execute(["a",])
None
>>> tests.clean_up()
"""
+ options, args = get_parser().parse_args(args)
if len(args) > 2:
raise cmdutil.UserError("Too many arguments.")
tree = cmdutil.bug_tree()
@@ -49,9 +50,11 @@ def execute(args):
del tree.settings[args[0]]
tree.save_settings()
-def help():
- return """be set [name] [value]
+def get_parser():
+ parser = cmdutil.CmdOptionParser("be set [name] [value]")
+ return parser
+longhelp="""
Show or change per-tree settings.
If name and value are supplied, the name is set to a new value.
@@ -66,3 +69,6 @@ target
To unset a setting, set it to "none".
"""
+
+def help():
+ return get_parser().help_str() + longhelp
diff --git a/becommands/severity.py b/becommands/severity.py
index 88d3f25..92c83fc 100644
--- a/becommands/severity.py
+++ b/becommands/severity.py
@@ -25,16 +25,17 @@ def execute(args):
>>> import os
>>> dir = tests.simple_bug_dir()
>>> os.chdir(dir.dir)
- >>> execute(("a",))
+ >>> execute(["a",])
minor
- >>> execute(("a", "wishlist"))
- >>> execute(("a",))
+ >>> execute(["a", "wishlist"])
+ >>> execute(["a",])
wishlist
- >>> execute(("a", "none"))
+ >>> execute(["a", "none"])
Traceback (most recent call last):
UserError: Invalid severity level: none
>>> tests.clean_up()
"""
+ options, args = get_parser().parse_args(args)
assert(len(args) in (0, 1, 2))
if len(args) == 0:
print help()
@@ -51,10 +52,11 @@ def execute(args):
raise cmdutil.UserError ("Invalid severity level: %s" % e.value)
bug.save()
+def get_parser():
+ parser = cmdutil.CmdOptionParser("be severity bug-id [severity]")
+ return parser
-def help():
- return """be severity bug-id [severity]
-
+longhelp="""
Show or change a bug's severity level.
If no severity is specified, the current value is printed. If a severity level
@@ -67,3 +69,6 @@ wishlist: A feature that could improve usefulness, but not a bug.
critical: A bug that prevents some features from working at all.
fatal: A bug that makes the package unusable.
"""
+
+def help():
+ return get_parser().help_str() + longhelp
diff --git a/becommands/show.py b/becommands/show.py
index 9e60586..8e83a1f 100644
--- a/becommands/show.py
+++ b/becommands/show.py
@@ -19,9 +19,10 @@ from libbe import bugdir, cmdutil, utility
import os
def execute(args):
- bug_dir = cmdutil.bug_tree()
+ options, args = get_parser().parse_args(args)
if len(args) !=1:
raise cmdutil.UserError("Please specify a bug id.")
+ bug_dir = cmdutil.bug_tree()
bug = cmdutil.get_bug(args[0], bug_dir)
print cmdutil.bug_summary(bug, list(bug_dir.list())).rstrip("\n")
if bug.time is None:
@@ -30,8 +31,22 @@ def execute(args):
time_str = "%s (%s)" % (utility.handy_time(bug.time),
utility.time_to_str(bug.time))
print "Created: %s" % time_str
- for comment in bug.list_comments():
- print "--------- Comment ---------"
- print "From: %s" % comment.From
- print "Date: %s\n" % utility.time_to_str(comment.date)
- print comment.body.rstrip('\n')
+ unique_name = cmdutil.unique_name(bug, bug_dir.list())
+ comments = []
+ name_map = {}
+ for c_name, comment in cmdutil.iter_comment_name(bug, unique_name):
+ name_map[comment.uuid] = c_name
+ comments.append(comment)
+ threaded = bugdir.thread_comments(comments)
+ cmdutil.print_threaded_comments(threaded, name_map)
+
+def get_parser():
+ parser = cmdutil.CmdOptionParser("be show bug-id")
+ return parser
+
+longhelp="""
+Show all information about a bug.
+"""
+
+def help():
+ return get_parser().help_str() + longhelp
diff --git a/becommands/target.py b/becommands/target.py
index d077da5..f872abb 100644
--- a/becommands/target.py
+++ b/becommands/target.py
@@ -25,16 +25,17 @@ def execute(args):
>>> import os
>>> dir = tests.simple_bug_dir()
>>> os.chdir(dir.dir)
- >>> execute(("a",))
+ >>> execute(["a",])
No target assigned.
- >>> execute(("a", "tomorrow"))
- >>> execute(("a",))
+ >>> execute(["a", "tomorrow"])
+ >>> execute(["a",])
tomorrow
- >>> execute(("a", "none"))
- >>> execute(("a",))
+ >>> execute(["a", "none"])
+ >>> execute(["a",])
No target assigned.
>>> tests.clean_up()
"""
+ options, args = get_parser().parse_args(args)
assert(len(args) in (0, 1, 2))
if len(args) == 0:
print help()
@@ -52,10 +53,11 @@ def execute(args):
bug.target = args[1]
bug.save()
+def get_parser():
+ parser = cmdutil.CmdOptionParser("be target bug-id [target]")
+ return parser
-def help():
- return """be target bug-id [target]
-
+longhelp="""
Show or change a bug's target for fixing.
If no target is specified, the current value is printed. If a target
@@ -66,3 +68,6 @@ milestone names or release numbers.
The value "none" can be used to unset the target.
"""
+
+def help():
+ return get_parser().help_str() + longhelp
diff --git a/becommands/upgrade.py b/becommands/upgrade.py
index 0cbffa1..3dcb4eb 100644
--- a/becommands/upgrade.py
+++ b/becommands/upgrade.py
@@ -17,9 +17,10 @@
"""Upgrade the bugs to the latest format"""
import os.path
import errno
-from libbe import bugdir, rcs
+from libbe import bugdir, rcs, cmdutil
def execute(args):
+ options, args = get_parser().parse_args(args)
root = bugdir.tree_root(".", old_version=True)
for uuid in root.list_uuids():
old_bug = OldBug(root.bugs_path, uuid)
@@ -98,5 +99,13 @@ class OldBug(object):
else:
rcs.set_file_contents(self.get_path(name), "%s\n" % value)
+def get_parser():
+ parser = cmdutil.CmdOptionParser("be upgrade")
+ return parser
+longhelp="""
+Upgrade the bug storage to the latest format.
+"""
+def help():
+ return get_parser().help_str() + longhelp