summaryrefslogtreecommitdiffstats
path: root/Lib/cmd.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1999-03-12 22:15:43 (GMT)
committerGuido van Rossum <guido@python.org>1999-03-12 22:15:43 (GMT)
commitd5138caba5fac644571cd7fa013d1ab0d4f867b6 (patch)
treec0040771d01496ea698cdc4ff7c2bc1c4186c04a /Lib/cmd.py
parent7039f50828473a030123d2bc2990532bcac9b5d9 (diff)
downloadcpython-d5138caba5fac644571cd7fa013d1ab0d4f867b6.zip
cpython-d5138caba5fac644571cd7fa013d1ab0d4f867b6.tar.gz
cpython-d5138caba5fac644571cd7fa013d1ab0d4f867b6.tar.bz2
Patch by Michael Scharf. He writes:
The module cmd requires for each do_xxx command a help_xxx function. I think this is a little old fashioned. Here is a patch: use the docstring as help if no help_xxx function can be found. [I'm tempted to rip out all the help_* functions from pdb, but I'll resist it. Any takers? --Guido]
Diffstat (limited to 'Lib/cmd.py')
-rw-r--r--Lib/cmd.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/cmd.py b/Lib/cmd.py
index 138cdb6..9ca0010 100644
--- a/Lib/cmd.py
+++ b/Lib/cmd.py
@@ -127,6 +127,13 @@ class Cmd:
try:
func = getattr(self, 'help_' + arg)
except:
+ try:
+ doc=getattr(self, 'do_' + arg).__doc__
+ if doc:
+ print doc
+ return
+ except:
+ pass
print self.nohelp % (arg,)
return
func()
@@ -159,6 +166,8 @@ class Cmd:
if help.has_key(cmd):
cmds_doc.append(cmd)
del help[cmd]
+ elif getattr(self, name).__doc__:
+ cmds_doc.append(cmd)
else:
cmds_undoc.append(cmd)
print self.doc_leader