better naming
authorAlexander Solovyov <piranha@piranha.org.ua>
Sun, 28 Jun 2009 13:54:42 +0300
changeset 24 57009da05d69
parent 23 3cd126244055
child 25 2854f81bfc8b
better naming
fancycmd.py
--- a/fancycmd.py	Sun Jun 28 10:19:15 2009 +0300
+++ b/fancycmd.py	Sun Jun 28 13:54:42 2009 +0300
@@ -14,7 +14,7 @@
 def fancyopts(cmd, options, usage):
     def inner(args):
         if not args:
-            cmd_help(cmd, usage, options)
+            help_cmd(cmd, usage, options)
         else:
             opts, args = parse(args, options)
             cmd(*args, **opts)
@@ -116,10 +116,10 @@
             return helplist()
 
         aliases, (cmd, options, usage) = findcmd(name, cmdtable)
-        return cmd_help(cmd, aliases[0]  + ' ' + usage, options)
+        return help_cmd(cmd, aliases[0]  + ' ' + usage, options)
     return inner
 
-def cmd_help(cmd, usage, options):
+def help_cmd(func, usage, options):
     '''show help for given command
 
     >>> def test(*args, **opts):
@@ -135,7 +135,7 @@
     ...          'daemonize process'),
     ...         ('', 'pid-file', '',
     ...          'name of file to write process ID to')]
-    >>> cmd_help(test, 'test [-l HOST] [NAME]', opts)
+    >>> help_cmd(test, 'test [-l HOST] [NAME]', opts)
     test [-l HOST] [NAME]
     <BLANKLINE>
     that's a test command
@@ -151,7 +151,7 @@
     <BLANKLINE>
     '''
     print '%s\n' % usage
-    doc = cmd.__doc__
+    doc = func.__doc__
     if not doc:
         doc = '(no help text available)'
     print '%s\n' % doc.strip()
@@ -279,14 +279,14 @@
 
         aliases, info = findcmd(cmd, cmdtable)
         cmd = aliases[0]
-        possibleargs = list(info[1])
+        possibleopts = list(info[1])
     else:
-        possibleargs = []
+        possibleopts = []
 
-    possibleargs.extend(globalopts)
+    possibleopts.extend(globalopts)
 
     try:
-        options, args = parse(args, possibleargs)
+        options, args = parse(args, possibleopts)
     except getopt.GetoptError, e:
         raise ParseError(cmd, e)