Made comment work with an editor
authorAaron Bentley <abentley@panoramicfeedback.com>
Wed, 23 Mar 2005 18:35:02 +0000 (18:35 +0000)
committerAaron Bentley <abentley@panoramicfeedback.com>
Wed, 23 Mar 2005 18:35:02 +0000 (18:35 +0000)
becommands/comment.py

index f16296986a0699c9359088ca290d81ec13b39d9a..358acd2711f7f462b420fa6ca9676951fb863806 100644 (file)
@@ -1,12 +1,21 @@
 """Add a comment to a bug"""
-from libbe import bugdir, cmdutil, names
+from libbe import bugdir, cmdutil, names, utility
 import os
 def execute(args):
     options, args = get_parser().parse_args(args)
-    if len(args) < 2:
+    if len(args) < 1:
         raise cmdutil.UsageError()
     bug = cmdutil.get_bug(args[0])
-    comment = bugdir.new_comment(bug, args[1])
+    if len(args) == 1:
+        body = utility.editor_string()
+        if body is None:
+            raise cmdutil.UserError("No comment entered.")
+    else:
+        body = args[1]
+        if not body.endswith('\n'):
+            body+='\n'
+
+    comment = bugdir.new_comment(bug, body)
     comment.save()