--- a/opster.py Wed Feb 10 10:31:27 2010 +0200
+++ b/opster.py Thu Feb 11 18:48:44 2010 +0200
@@ -232,6 +232,8 @@
yield 'options:\n\n'
output = []
for short, name, default, desc in options:
+ if hasattr(default, '__call__'):
+ default = default(None)
default = default and ' (default: %s)' % default or ''
output.append(('%2s%s' % (short and '-%s' % short,
name and ' --%s' % name),
--- a/tests/test_opts.out Wed Feb 10 10:31:27 2010 +0200
+++ b/tests/test_opts.out Thu Feb 11 18:48:44 2010 +0200
@@ -10,6 +10,7 @@
-p --port port to listen on (default: 8000)
-d --daemonize daemonize process
--pid-file name of file to write process ID to
+ -t --test testing help for a function (default: test)
-h --help show help
test_opts.py [-l HOST] DIR
@@ -23,5 +24,6 @@
-p --port port to listen on (default: 8000)
-d --daemonize daemonize process
--pid-file name of file to write process ID to
+ -t --test testing help for a function (default: test)
-h --help show help
-{'pid_file': '', 'daemonize': False, 'dirname': '.', 'port': 8000, 'listen': 'localhost'}
+{'pid_file': '', 'daemonize': False, 'test': 'test', 'dirname': '.', 'port': 8000, 'listen': 'localhost'}
--- a/tests/test_opts.py Wed Feb 10 10:31:27 2010 +0200
+++ b/tests/test_opts.py Thu Feb 11 18:48:44 2010 +0200
@@ -22,7 +22,8 @@
listen=('l', 'localhost', 'ip to listen on'),
port=('p', 8000, 'port to listen on'),
daemonize=('d', False, 'daemonize process'),
- pid_file=('', '', 'name of file to write process ID to')):
+ pid_file=('', '', 'name of file to write process ID to'),
+ test=('t', lambda x: x or 'test', 'testing help for a function')):
'''Command with option declaration as keyword arguments
Otherwise it's the same as previous command