summaryrefslogtreecommitdiff
path: root/Lib/cmd.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1994-08-01 11:34:53 +0000
committerGuido van Rossum <guido@python.org>1994-08-01 11:34:53 +0000
commit31bcad2a833517df724fc6ca8335190170174b8f (patch)
tree4467846eced619192a031837d76b2186f28a395f /Lib/cmd.py
parentc660f7fcd25eb9d5c9ce72899c5f4a66141136d8 (diff)
downloadcpython-31bcad2a833517df724fc6ca8335190170174b8f.tar.gz
Merge alpha100 branch back to main trunk
Diffstat (limited to 'Lib/cmd.py')
-rw-r--r--Lib/cmd.py34
1 files changed, 31 insertions, 3 deletions
diff --git a/Lib/cmd.py b/Lib/cmd.py
index 87ddcfa7e7..85115bb9b5 100644
--- a/Lib/cmd.py
+++ b/Lib/cmd.py
@@ -56,8 +56,36 @@ class Cmd:
else:
import newdir
names = newdir.dir(self.__class__)
- cmds = []
+ cmds_doc = []
+ cmds_undoc = []
+ help = {}
+ for name in names:
+ if name[:5] == 'help_':
+ help[name[5:]]=1
for name in names:
if name[:3] == 'do_':
- cmds.append(name[3:])
- print cmds
+ cmd=name[3:]
+ if help.has_key(cmd):
+ cmds_doc.append(cmd)
+ del help[cmd]
+ else:
+ cmds_undoc.append(cmd)
+ print
+ self.print_topics("Documented commands (type help " \
+ "<topic>):",cmds_doc, 15, 80)
+ self.print_topics("Miscellaneous help topics:",
+ help.keys(), 15, 80)
+ self.print_topics("Undocumented commands:",
+ cmds_undoc, 15, 80)
+
+ def print_topics(self, header, cmds, cmdlen, maxcol):
+ if cmds:
+ print header;
+ print "="*len(header)
+ (cmds_per_line,junk)=divmod(maxcol,cmdlen)
+ col=cmds_per_line
+ for cmd in cmds:
+ if col==0: print
+ print (("%-"+`cmdlen`+"s") % cmd),
+ col = (col+1) % cmds_per_line
+ print "\n"