Make the full UUIDs optional for `new` and `comment`.
authorW. Trevor King <wking@drexel.edu>
Sat, 3 Mar 2012 15:49:03 +0000 (10:49 -0500)
committerW. Trevor King <wking@drexel.edu>
Sat, 3 Mar 2012 15:49:13 +0000 (10:49 -0500)
This makes the default output less threatening for new users, while
still supplying the full UUIDs for driving BE from external software.

libbe/command/comment.py
libbe/command/new.py

index 74521d14c6af46bd4b8a6139b19601b9c43636ef..cd04df1b0fa5e0b0623bbc83a52ea1e691c35c5b 100644 (file)
@@ -107,6 +107,8 @@ class Comment (libbe.command.Command):
                     help='Set comment content-type (e.g. text/plain)',
                     arg=libbe.command.Argument(name='content-type',
                         metavar='MIME')),
+                libbe.command.Option(name='full-uuid', short_name='f',
+                    help='Print the full UUID for the new bug')
                 ])
         self.args.extend([
                 libbe.command.Argument(
@@ -159,7 +161,11 @@ class Comment (libbe.command.Command):
         for key in ['alt-id', 'author']:
             if params[key] != None:
                 setattr(new, new._setting_name_to_attr_name(key), params[key])
-        print >> self.stdout, 'Created comment with ID %s (%s)' % (new.id.user(), new.id.long_user())
+        if params['full-uuid']:
+            comment_id = new.id.long_user()
+        else:
+            comment_id = new.id.user()
+        self.stdout.write('Created comment with ID %s\n' % (comment_id))
         return 0
 
     def _long_help(self):
index a847132eac14e9a4652f714cb9bc69d0076d4fe3..725326eb797635528bf23f3a7e340cc989833cf1 100644 (file)
@@ -95,6 +95,8 @@ class New (libbe.command.Command):
                     arg=libbe.command.Argument(
                         name='severity', metavar='SEVERITY',
                         completion_callback=libbe.command.util.complete_severity)),
+                libbe.command.Option(name='full-uuid', short_name='f',
+                    help='Print the full UUID for the new bug')
                 ])
         self.args.extend([
                 libbe.command.Argument(name='summary', metavar='SUMMARY')
@@ -124,7 +126,11 @@ class New (libbe.command.Command):
             bug.severity = params['severity']
         bugdir.storage.writeable = True
         bug.save()
-        print >> self.stdout, 'Created bug with ID %s (%s)' % (bug.id.user(), bug.id.long_user())
+        if params['full-uuid']:
+            bug_id = bug.id.long_user()
+        else:
+            bug_id = bug.id.user()
+        self.stdout.write('Created bug with ID %s\n' % (bug_id))
         return 0
 
     def _long_help(self):