[Repoze-checkins] r1106 - compoze/trunk/compoze
Rocky Burt
rocky at serverzen.com
Thu Jun 19 13:19:36 EDT 2008
Author: Rocky Burt <rocky at serverzen.com>
Date: Thu Jun 19 13:19:36 2008
New Revision: 1106
Log:
Valid commands prompt now displays docstrings.
Modified:
compoze/trunk/compoze/compozer.py
compoze/trunk/compoze/pooler.py
Modified: compoze/trunk/compoze/compozer.py
==============================================================================
--- compoze/trunk/compoze/compozer.py (original)
+++ compoze/trunk/compoze/compozer.py Thu Jun 19 13:19:36 2008
@@ -3,6 +3,7 @@
"""
import optparse
import pkg_resources
+import textwrap
import sys
@@ -23,6 +24,14 @@
_COMMANDS[entry.name] = klass
+def get_description(command):
+ klass = _COMMANDS[command]
+ doc = getattr(klass, '__doc__', '')
+ if doc is None:
+ return ''
+ return ' '.join([x.lstrip() for x in doc.split('\n')])
+
+
class Compozer:
def __init__(self, argv=None):
@@ -81,8 +90,15 @@
if options.help_commands:
keys = _COMMANDS.keys()
keys.sort()
- val = 'Valid commands are: ' + ' '.join(keys)
- raise ValueError(val)
+ print 'Valid commands are:'
+ for x in keys:
+ print ' ', x
+ doc = get_description(x)
+ if doc:
+ print textwrap.fill(doc,
+ initial_indent=' ',
+ subsequent_indent=' ')
+ return
for command_name, args in queue:
if command_name is not None:
Modified: compoze/trunk/compoze/pooler.py
==============================================================================
--- compoze/trunk/compoze/pooler.py (original)
+++ compoze/trunk/compoze/pooler.py Thu Jun 19 13:19:36 2008
@@ -1,6 +1,3 @@
-""" compoze pool -- move all archives into a common pool directory
-
-"""
import optparse
import os
import shutil
@@ -21,6 +18,9 @@
class Pooler(object):
+ '''Move all archives into a common pool directory and symlink back the
+ results.
+ '''
def __init__(self, global_options, *argv):
More information about the Repoze-checkins
mailing list