commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue/gnue-common/src GBaseApp.py


From: Jason Cater
Subject: gnue/gnue-common/src GBaseApp.py
Date: Mon, 22 Oct 2001 12:33:20 -0400

CVSROOT:        /home/cvs
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    01/10/22 12:33:20

Modified files:
        gnue-common/src: GBaseApp.py 

Log message:
        Cleaned up the help printout

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/src/GBaseApp.py.diff?cvsroot=OldCVS&tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: gnue/gnue-common/src/GBaseApp.py
diff -u gnue/gnue-common/src/GBaseApp.py:1.4 
gnue/gnue-common/src/GBaseApp.py:1.5
--- gnue/gnue-common/src/GBaseApp.py:1.4        Thu Oct 18 15:54:05 2001
+++ gnue/gnue-common/src/GBaseApp.py    Mon Oct 22 12:33:20 2001
@@ -196,47 +196,44 @@
   #
   def printHelp(self): 
     allOptions = {}
+    descriptors = {}
     maxLength = 0
-    maxArg = 0
+
     for optionset in [self._base_options, self.COMMAND_OPTIONS]: 
       for option in optionset:  
-#        if option[1] != None: 
-#          allOptions[string.upper(option[1]) + option[1]] = option
-#        else: 
         allOptions[string.upper(option[2])] = option
-        if len(option[2]) > maxLength: 
-          maxLength = len(option[2])
-        if option[3] and len(option[5]) > maxArg: 
-          maxArg = len(option[5])
 
+        if option[5]: 
+          descr = '--%s <%s>' % (option[2], option[5])
+        else: 
+          descr = '--%s' % (option[2])
+        if option[1]: 
+          descr += ', -%s' % option[1]
+
+        descriptors[string.upper(option[2])] = descr
+
+        if len(descr) > maxLength: 
+          maxLength = len(descr)
+
+    if maxLength > 20: 
+      maxLength = 20
+
     sorted = allOptions.keys()
     sorted.sort()
 
     dispOptions = ""
 
-    print maxLength
-
     for optionKey in sorted: 
-      if allOptions[optionKey][3]:
-        valMarker = (" <%s>" % allOptions[optionKey][5])
-        extraspace = " " * (maxArg-len(allOptions[optionKey][5]))
-      else: 
-        valMarker = ""
-        extraspace = " "*(maxArg+3)
-
-      if allOptions[optionKey][1] != None: 
-        short = ", -%s" % (allOptions[optionKey][1])
-      else: 
-        short = "    " 
 
-      dispOptions = dispOptions + "\n" +\
-           ("   --%s%s%s" % (allOptions[optionKey][2], valMarker, short)) +\
-           extraspace + \
-           (" "*(maxLength-len(allOptions[optionKey][2])))
-
-      margin = maxLength + 12 + maxArg
+      margin = maxLength + 4
       width = 78 - margin
       pos = 0
+
+      if len(descriptors[optionKey]) > maxLength: 
+        dispOptions += "\n  %s\n%s" % (descriptors[optionKey], " " * margin)
+      else: 
+        dispOptions += "\n  %s  %s" % (descriptors[optionKey],  
+               " " * (maxLength - len(descriptors[optionKey])))
 
       for word in string.split(allOptions[optionKey][6]): 
         if (len(word) + pos) > width: 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]