[svnbook] r3863 committed - * src/tools/bin/spew-svn-command-options...

svnbook at googlecode.com svnbook at googlecode.com
Thu Jun 30 11:12:06 CDT 2011


Revision: 3863
Author:   cmpilato at gmail.com
Date:     Thu Jun 30 09:11:10 2011
Log:      * src/tools/bin/spew-svn-command-options
   Teach this thing how to deal with binaries such as 'svnversion' and
   'svnserve' that don't have subcommands but do offer the --help
   option.
http://code.google.com/p/svnbook/source/detail?r=3863

Modified:
  /trunk/src/tools/bin/spew-svn-command-options

=======================================
--- /trunk/src/tools/bin/spew-svn-command-options	Fri Mar 20 05:51:31 2009
+++ /trunk/src/tools/bin/spew-svn-command-options	Thu Jun 30 09:11:10 2011
@@ -2,12 +2,36 @@
  import sys
  import os

+def find_options(lines):
+    found_header = 0
+    options = []
+    for line in lines:
+        line = line.rstrip()
+        if not found_header:
+            if line.startswith('Valid options:'):
+                found_header = 1
+            continue
+        if len(line) < 3:
+            break
+        if line[3] == ' ':
+            continue
+        option_parts = filter(None, line.split(' '))
+        if option_parts[0].startswith('--'):
+            option = option_parts[0]
+        else:
+            option = option_parts[1][1:-1]
+        options.append(option)
+    return options
+
  ### Change this as needed to point to the specific binaries you wanna  
query.
  tools = ['svn',
-         'svnlook',
           'svnadmin',
           'svndumpfilter',
+         'svnlook',
+         'svnrdump',
+         'svnserve',
           'svnsync',
+         'svnversion',
           ]

  for tool in tools:
@@ -27,29 +51,21 @@
          subcommands.append(subcommand)

      # For each subcommand, find the options.
-    subcommands.sort()
-    for subcommand in subcommands:
-        lines = os.popen("%s help %s" % (tool,  
subcommand), 'r').readlines()
-        found_header = 0
-        options = []
-        for line in lines:
-            line = line.rstrip()
-            if not found_header:
-                if line.startswith('Valid options:'):
-                    found_header = 1
-                continue
-            if len(line) < 3:
-                break
-            if line[3] == ' ':
-                continue
-            option_parts = filter(None, line.split(' '))
-            if option_parts[0].startswith('--'):
-                option = option_parts[0]
-            else:
-                option = option_parts[1][1:-1]
-            options.append(option)
-
-        print "%s %s" % (os.path.basename(tool), subcommand)
+    if subcommands:
+        subcommands.sort()
+        for subcommand in subcommands:
+            lines = os.popen("%s help %s" %
+                             (tool, subcommand), 'r').readlines()
+            options = find_options(lines)
+            print "%s %s" % (os.path.basename(tool), subcommand)
+            options.sort()
+            for option in options:
+                print "%s %s %s" % (os.path.basename(tool), subcommand,  
option)
+    else:
+        lines = os.popen("%s --help" % (tool), 'r').readlines()
+        options = find_options(lines)
+        print "%s" % (os.path.basename(tool))
          options.sort()
          for option in options:
-            print "%s %s %s" % (os.path.basename(tool), subcommand, option)
+            print "%s %s" % (os.path.basename(tool), option)
+




More information about the svnbook-dev mailing list