Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

bpo-37030: hide undocumented commands in cmd module#13536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
aldwinaldwin wants to merge5 commits intopython:main
base:main
Choose a base branch
Loading
fromaldwinaldwin:cmd_hide_undoc

Conversation

aldwinaldwin
Copy link
Contributor

@aldwinaldwinaldwinaldwin commentedMay 24, 2019
edited by bedevere-bot
Loading

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).

https://bugs.python.org/issue37030

…enamesA flag, defaulting to false. If true, :meth:`do_help` and :meth:`completenames`won't include undocumented commands (that is, there are do_*() methods withoutcorresponding help_*() methods).
Copy link
Member

@tirkarthitirkarthi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Left comment for doc and test. But in general would like to hear from a core dev on this.

return [a[3:] for a in self.get_names() if a.startswith(dotext)]
names = self.get_names()
commands = [a[3:] for a in names if a.startswith(dotext)]
if self.hide_undoc:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Please add a test similar to

>>> mycmd.completenames("a")
. In the doctest you can setmycmd.hide_undoc = True and make sure "shell" is not returned by thecompletenames function for "s". Set itmycmd.hide_undoc = False for rest of the tests to make sure to make sure other tests are not affected.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

ok, figured it out and made commit.

@aldwinaldwinaldwinaldwin changed the titlebpo-37030: Lib/cmd.py: Hide undocumented commandsbpo-37030: Lib/cmd.py: Hide undocumented commands. (GH-13536)May 31, 2019
@merwokmerwok changed the titlebpo-37030: Lib/cmd.py: Hide undocumented commands. (GH-13536)bpo-37030: hide undocumented commands in cmd mobuleJun 13, 2019
@vsajipvsajip changed the titlebpo-37030: hide undocumented commands in cmd mobulebpo-37030: hide undocumented commands in cmd moduleJun 19, 2019
@aldwinaldwin
Copy link
ContributorAuthor

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

: please review the changes made to this pull request.

kimbo added a commit to kimbo/cpython that referenced this pull requestNov 7, 2019
The 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 ofREPL, you often want to exit when when you get an EOF (for example,python's REPL exits when you press ctrl + d). The way toachieve that functionality here is to create a functioncalled `do_EOF` in your subclass of `cmd.Cmd`, and call `exit()`If you want some other behavior when you get an EOF, you can putthat in `do_EOF` instead.This is problematic for two main reasons:1. `EOF` shows up as an undocumented command when you type `help`. It'snot that big of a deal, but it's definitely not ideal (and perhapsconfusing).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 theprogram. Seems rather silly.I propose the cmd class NOT catch the EOFError. That will eliminate bothof the above problems. I realize this could be an issue with backwardscompatibility and such, but I don't think it would require muchadjustment (maybe a couple lines).See alsohttps://bugs.python.org/issue13214 andpython#13536
@rhettinger
Copy link
Contributor

Why would we want to encourage undocumented commands? This seems like an anti-pattern to me.

@aldwinaldwin
Copy link
ContributorAuthor

The reason was to have some secret functions for professional users or to have some try out functions that normal users would not start calling support about immediately. On the other had it bothered me that they are in the list to ask help for, while there is no help available for these anyway.

@python-cla-bot
Copy link

python-cla-botbot commentedApr 18, 2025
edited
Loading

All commit authors signed the Contributor License Agreement.

CLA signed

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tirkarthitirkarthitirkarthi left review comments

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@aldwinaldwin@bedevere-bot@rhettinger@tirkarthi@the-knights-who-say-ni@ezio-melotti

[8]ページ先頭

©2009-2025 Movatter.jp