bpo-37030: hide undocumented commands in cmd module by aldwinaldwin · Pull Request #13536 · python/cpython
…enames A flag, defaulting to false. If true, :meth:`do_help` and :meth:`completenames` won't include undocumented commands (that is, there are do_*() methods without corresponding help_*() methods).
aldwinaldwin
changed the title
bpo-37030: Lib/cmd.py: Hide undocumented commands
bpo-37030: Lib/cmd.py: Hide undocumented commands. (GH-13536)
merwok
changed the title
bpo-37030: Lib/cmd.py: Hide undocumented commands. (GH-13536)
bpo-37030: hide undocumented commands in cmd mobule
vsajip
changed the title
bpo-37030: hide undocumented commands in cmd mobule
bpo-37030: hide undocumented commands in cmd module
kimbo added a commit to kimbo/cpython that referenced this pull request
Nov 7, 2019The current behavior of the cmd module is to return the string 'EOF' when the program receives an EOF (e.g. when you press ctrl + d, or when the end of a file is reached). When you're writing some kind of REPL, you often want to exit when when you get an EOF (for example, python's REPL exits when you press ctrl + d). The way to achieve that functionality here is to create a function called `do_EOF` in your subclass of `cmd.Cmd`, and call `exit()` If you want some other behavior when you get an EOF, you can put that in `do_EOF` instead. This is problematic for two main reasons: 1. `EOF` shows up as an undocumented command when you type `help`. It's not that big of a deal, but it's definitely not ideal (and perhaps confusing). 2. If you type `EOF` into the terminal, it will call your `do_EOF` function. If your `do_EOF` function exits, typing `do_EOF` will exit the program. Seems rather silly. I propose the cmd class NOT catch the EOFError. That will eliminate both of the above problems. I realize this could be an issue with backwards compatibility and such, but I don't think it would require much adjustment (maybe a couple lines). See also https://bugs.python.org/issue13214 and python#13536
kimbo
mentioned this pull request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters