Add better help message on COMMAND-less be call
authorW. Trevor King <wking@drexel.edu>
Wed, 20 Jan 2010 12:19:56 +0000 (07:19 -0500)
committerW. Trevor King <wking@drexel.edu>
Wed, 20 Jan 2010 12:19:56 +0000 (07:19 -0500)
libbe/ui/command_line.py

index 7ba6cf5b20b78ec9159ffce29fdcf348cae3ded3..17f7b35cd50de82bbb059dd71a78d59a07cdf8e1 100644 (file)
@@ -285,7 +285,14 @@ def main():
     except CallbackExit:
         return 0
     except libbe.command.UserError, e:
-        print >> ui.io.stdout, 'ERROR:\n', e
+        if str(e).endswith('COMMAND'):
+            # no command given, print usage string
+            print >> ui.io.stdout, 'ERROR:'
+            print >> ui.io.stdout, be.usage(), '\n', e
+            print >> ui.io.stdout, 'For example, try'
+            print >> ui.io.stdout, '  be help'
+        else:
+            print >> ui.io.stdout, 'ERROR:\n', e
         return 1
 
     command_name = args.pop(0)