Message232948
cmd.Cmd has a documented do_help(self, arg) method (written in 2000). If arg is '', it prints
1. Documented commands (do_x with help_x or do_x.__doc__ != ''), sorted
2. Other help topics (help_y with no do_y), unsorted
3. Undocumented commands (do_ without no help_x and no do_x.__doc__), sorted
The dict called 'help' (which should be a set, and might better be called 'topics') ends up with a member for each help_y topic without a do_y command. Not sorting the keys is at least a design bug. Leaving users aside, it makes do_help unpredictable and hard to test. Our test.test_cmd omits misc help topics. In verbose mode, it prints
Trying:
mycmd.do_help("")
Expecting:
<BLANKLINE>
Documented commands (type help <topic>):
========================================
add help
<BLANKLINE>
Undocumented commands:
======================
exit shell
<BLANKLINE>
ok
As near as I can tell, text_cmd would still pass if Misc topics were removed and never printed. Topics can only be added to the test above is they are dependably ordered (ie, sorted).
---
This '?' or 'help' case is also not properly documented, but should be. 3.4 cmd.__doc__ has this mishmash:
"With no arguments, it lists all topics with defined help_ functions, broken into up to three topics; documented commands, miscellaneous help topics, and undocumented commands."
3.4 doc says "With no argument, do_help() lists all available help topics (that is, all commands with corresponding help_*() methods or commands that have docstrings), and also lists any undocumented commands." |
|
Date |
User |
Action |
Args |
2014-12-19 21:45:41 | terry.reedy | set | recipients:
+ terry.reedy, samwyse |
2014-12-19 21:45:41 | terry.reedy | set | messageid: <1419025541.5.0.854424396364.issue23059@psf.upfronthosting.co.za> |
2014-12-19 21:45:41 | terry.reedy | link | issue23059 messages |
2014-12-19 21:45:41 | terry.reedy | create | |
|