aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-06-19 16:26:01 -0400
committerW. Trevor King <wking@drexel.edu>2009-06-19 16:26:01 -0400
commit133fdec6db0e01e77cc99d81cccd254dc1191dcc (patch)
tree837b634c041ac8e2a8dda22fc79d907624560b00
parent9fb7b0d84872c9db0bb33ea791874e147c7e5f0d (diff)
downloadbugseverywhere-133fdec6db0e01e77cc99d81cccd254dc1191dcc.tar.gz
Added comments-from-stdin, so we can add tracebacks, e.g. with
$ be list --invalid-option | be comment <bug-id> -
-rw-r--r--.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/comments/d83a5436-85e3-42c7-9a89-a6d50df9d279/body4
-rw-r--r--.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/comments/d83a5436-85e3-42c7-9a89-a6d50df9d279/values8
-rw-r--r--.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/values31
-rw-r--r--becommands/comment.py21
4 files changed, 31 insertions, 33 deletions
diff --git a/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/comments/d83a5436-85e3-42c7-9a89-a6d50df9d279/body b/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/comments/d83a5436-85e3-42c7-9a89-a6d50df9d279/body
new file mode 100644
index 0000000..118afc8
--- /dev/null
+++ b/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/comments/d83a5436-85e3-42c7-9a89-a6d50df9d279/body
@@ -0,0 +1,4 @@
+I've added comments-from-stdin, so we can add tracebacks, e.g. with
+
+ $ be list --invalid-option | be comment <bug-id> -
+
diff --git a/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/comments/d83a5436-85e3-42c7-9a89-a6d50df9d279/values b/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/comments/d83a5436-85e3-42c7-9a89-a6d50df9d279/values
new file mode 100644
index 0000000..4aea60a
--- /dev/null
+++ b/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/comments/d83a5436-85e3-42c7-9a89-a6d50df9d279/values
@@ -0,0 +1,8 @@
+Content-type: text/plain
+
+
+Date: Fri, 19 Jun 2009 20:22:19 +0000
+
+
+From: W. Trevor King <wking@drexel.edu>
+
diff --git a/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/values b/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/values
index eb2c67f..7d5bb11 100644
--- a/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/values
+++ b/.be/bugs/576e804a-8b76-4876-8e9d-d7a72b0aef10/values
@@ -1,35 +1,14 @@
+creator: abentley
+severity: minor
-creator=abentley
+status: open
+summary: Allow attachments
-
-severity=minor
-
-
-
-
-
-
-status=open
-
-
-
-
-
-
-summary=Allow attachments
-
-
-
-
-
-
-time=Wed, 25 Jan 2006 15:43:46 +0000
-
-
+time: Wed, 25 Jan 2006 15:43:46 +0000
diff --git a/becommands/comment.py b/becommands/comment.py
index b15a06e..29e9f88 100644
--- a/becommands/comment.py
+++ b/becommands/comment.py
@@ -17,6 +17,7 @@
"""Add a comment to a bug"""
from libbe import cmdutil, bugdir, settings_object, editor
import os
+import sys
__desc__ = __doc__
def execute(args, test=False):
@@ -83,7 +84,7 @@ def execute(args, test=False):
else:
parent = bug.comment_root
- if len(args) == 1:
+ if len(args) == 1: # try to launch an editor for comment-body entry
try:
body = editor.editor_string("Please enter your comment above")
except editor.CantFindEditor, e:
@@ -91,7 +92,11 @@ def execute(args, test=False):
if body is None:
raise cmdutil.UserError("No comment entered.")
body = body.decode('utf-8')
- else:
+ elif args[1] == '-': # read body from stdin
+ body = sys.stdin.read()
+ if not body.endswith('\n'):
+ body+='\n'
+ else: # body = arg[1]
body = args[1]
if not body.endswith('\n'):
body+='\n'
@@ -100,14 +105,16 @@ def execute(args, test=False):
bd.save()
def get_parser():
- parser = cmdutil.CmdOptionParser("be comment ID COMMENT")
+ parser = cmdutil.CmdOptionParser("be comment ID [COMMENT]")
return parser
longhelp="""
-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
+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). COMMENT, if specified, should be either the text of your
+comment or "-", in which case the text will be read from stdin. If
+you do not specify a COMMENT, $EDITOR is used to launch an editor. If
+COMMENT is unspecified and EDITOR is not set, no comment will be
created.
"""