fix sysname to not display full path to command
authorAlexander Solovyov <alexander@solovyov.net>
Thu, 18 Nov 2010 22:19:30 +0100
changeset 137 3b2fcbad96d7
parent 136 57444e973879
child 138 e21e182229c1
fix sysname to not display full path to command
opster.py
tests/opster.t
--- a/opster.py	Thu Nov 18 22:15:57 2010 +0100
+++ b/opster.py	Thu Nov 18 22:19:30 2010 +0100
@@ -473,7 +473,7 @@
         help_func(e.args[0])
         raise Abort()
     except getopt.GetoptError, e:
-        err('error: %s\n' % e)
+        err('error: %s\n\n' % e)
         help_func()
         raise Abort()
     except OpsterError, e:
@@ -512,7 +512,9 @@
 
 def sysname():
     name = sys.argv[0]
-    if name.startswith('./'):
+    if name.startswith('/'):
+        return name.rsplit('/', 1)[1]
+    elif name.startswith('./'):
         return name[2:]
     return name
 
--- a/tests/opster.t	Thu Nov 18 22:15:57 2010 +0100
+++ b/tests/opster.t	Thu Nov 18 22:19:30 2010 +0100
@@ -8,7 +8,7 @@
 Check if usage is working::
 
   $ run multicommands.py
-  usage: /Users/piranha/dev/misc/opster/tests/multicommands.py <command> [options]
+  usage: multicommands.py <command> [options]
   
   commands:
   
@@ -23,7 +23,7 @@
 check it out::
 
   $ run multicommands.py help complex
-  /Users/piranha/dev/misc/opster/tests/multicommands.py complex [-p] [--exit value] ...
+  multicommands.py complex [-p] [--exit value] ...
   
   That's more complex command intended to do something
   
@@ -44,7 +44,7 @@
 
   $ run test_opts.py
   another: invalid arguments
-  /Users/piranha/dev/misc/opster/tests/test_opts.py [-l HOST] DIR
+  test_opts.py [-l HOST] DIR
   
   Command with option declaration as keyword arguments
   
@@ -71,7 +71,8 @@
 
   $ run test_opts.py --wrong-option
   error: option --wrong-option not recognized
-  /Users/piranha/dev/misc/opster/tests/test_opts.py [-l HOST] DIR
+  
+  test_opts.py [-l HOST] DIR
   
   Command with option declaration as keyword arguments