[Zope3-checkins] CVS: Zope3/src/zope/fssync - command.py:1.2
Fred L. Drake, Jr.
fred at zope.com
Tue Aug 12 13:51:50 EDT 2003
Update of /cvs-repository/Zope3/src/zope/fssync
In directory cvs.zope.org:/tmp/cvs-serv24703
Modified Files:
command.py
Log Message:
add a default "help" command similar to Subversion's if the
application hasn't registered it's own help command
=== Zope3/src/zope/fssync/command.py 1.1 => 1.2 ===
--- Zope3/src/zope/fssync/command.py:1.1 Mon Aug 11 16:55:21 2003
+++ Zope3/src/zope/fssync/command.py Tue Aug 12 12:51:45 2003
@@ -57,6 +57,8 @@
self.command_table[n] = cmdinfo
def realize(self, args=None):
+ if "help" not in self.command_table:
+ self.addCommand("help", self.help)
if args is None:
args = sys.argv[1:]
self.global_options, args = self.getopt("global",
@@ -92,3 +94,22 @@
def usage(self, file, text):
print >>file, text % {"program": self.program}
+
+ def help(self, opts, args):
+ if not args:
+ self.usage(sys.stdout, self.helptext)
+ else:
+ for cmd in args:
+ if cmd not in self.command_table:
+ print >>sys.stderr, "unknown command:", cmd
+ first = True
+ for cmd in args:
+ cmdinfo = self.command_table.get(cmd)
+ if cmdinfo is None:
+ continue
+ _, _, func = cmdinfo
+ if first:
+ first = False
+ else:
+ print
+ self.usage(sys.stdout, func.__doc__)
More information about the Zope3-Checkins
mailing list