[svnbook commit] r3373 - trunk/src/tools/bin
cmpilato
noreply at red-bean.com
Fri Dec 12 10:35:59 CST 2008
Author: cmpilato
Date: Fri Dec 12 10:35:58 2008
New Revision: 3373
Log:
* src/tools/bin/spew-svn-command-options.sh
Rename to...
* src/tools/bin/spew-svn-command-options
...this, and rework this script to print a consistent,
alphabetically sorted list of long options supported by various bits
of the Subversion toolchain. The goal, of course, being output that
is 'diff'able from version to version.
Added:
trunk/src/tools/bin/spew-svn-command-options
- copied, changed from r3333, /trunk/src/tools/bin/spew-svn-command-options.sh
Removed:
trunk/src/tools/bin/spew-svn-command-options.sh
Copied: trunk/src/tools/bin/spew-svn-command-options (from r3333, /trunk/src/tools/bin/spew-svn-command-options.sh)
==============================================================================
--- /trunk/src/tools/bin/spew-svn-command-options.sh (original)
+++ trunk/src/tools/bin/spew-svn-command-options Fri Dec 12 10:35:58 2008
@@ -1,8 +1,53 @@
-#!/bin/bash
+#!/usr/bin/env python
+import sys
+import os
-### Print 'svn' subcommands and their non-global, non-deprecated options. ###
+tools = ['svn',
+ 'svnlook',
+ 'svnadmin',
+ 'svndumpfilter',
+ 'svnsync',
+ ]
-for subcommand in `svn help | grep '^ [a-z]' | cut -f 4 -d ' '`; do
- echo "*** ${subcommand} ***"
- svn help ${subcommand} | cut -c3- | grep '^\-' | sort | grep -v '^-\(-username\|-password\|-non-interactive\|-no-auth-cache\|-config-dir\|N \)' | sed 's,^, ,'
-done
\ No newline at end of file
+for tool in tools:
+ # Find the subcommands for this tool.
+ lines = os.popen("%s help" % (tool), 'r').readlines()
+ found_header = 0
+ subcommands = []
+ for line in lines:
+ line = line.rstrip()
+ if not found_header:
+ if line.startswith('Available subcommands:'):
+ found_header = 1
+ continue
+ if not line:
+ break
+ subcommand = filter(None, line.split(' '))[0]
+ 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)
+
+ options.sort()
+ for option in options:
+ print "%s %s %s" % (tool, subcommand, option)
More information about the svnbook-dev
mailing list