Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--help for runnable stdlib modules #68832

Closed
anntzer mannequin opened this issue Jul 16, 2015 · 5 comments
Closed

--help for runnable stdlib modules #68832

anntzer mannequin opened this issue Jul 16, 2015 · 5 comments
Labels
stdlib Python modules in the Lib dir

Comments

@anntzer
Copy link
Mannequin

anntzer mannequin commented Jul 16, 2015

BPO 24644
Nosy @ezio-melotti, @bitdancer, @anntzer

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2015-07-16.18:47:09.952>
created_at = <Date 2015-07-16.16:30:57.512>
labels = ['library']
title = '--help for runnable stdlib modules'
updated_at = <Date 2015-07-17.14:11:39.204>
user = 'https://github.com/anntzer'

bugs.python.org fields:

activity = <Date 2015-07-17.14:11:39.204>
actor = 'ezio.melotti'
assignee = 'none'
closed = True
closed_date = <Date 2015-07-16.18:47:09.952>
closer = 'r.david.murray'
components = ['Library (Lib)']
creation = <Date 2015-07-16.16:30:57.512>
creator = 'Antony.Lee'
dependencies = []
files = []
hgrepos = []
issue_num = 24644
keywords = []
message_count = 5.0
messages = ['246808', '246811', '246835', '246852', '246855']
nosy_count = 3.0
nosy_names = ['ezio.melotti', 'r.david.murray', 'Antony.Lee']
pr_nums = []
priority = 'normal'
resolution = 'later'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue24644'
versions = ['Python 3.5']

@anntzer
Copy link
Mannequin Author

anntzer mannequin commented Jul 16, 2015

Support for python -m<runnable-stdlib-module> [-h|--help] is a bit patchy right now:

$ python -mpdb -h
usage: pdb.py [-c command] ... pyfile [arg] ...
<help elided>
$ python -mpdb --help
Traceback (most recent call last):
  File "/usr/lib/python3.4/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.4/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3.4/pdb.py", line 1685, in <module>
    pdb.main()
  File "/usr/lib/python3.4/pdb.py", line 1629, in main
    opts, args = getopt.getopt(sys.argv[1:], 'hc:', ['--help', '--command='])
  File "/usr/lib/python3.4/getopt.py", line 93, in getopt
    opts, args = do_longs(opts, args[0][2:], longopts, args[1:])
  File "/usr/lib/python3.4/getopt.py", line 157, in do_longs
    has_arg, opt = long_has_args(opt, longopts)
  File "/usr/lib/python3.4/getopt.py", line 174, in long_has_args
    raise GetoptError(_('option --%s not recognized') % opt, opt)
getopt.GetoptError: option --help not recognized
# <-- not a getopt specialist but --help is actually listed in the call to getopt!
$ python -mtrace -h
/usr/lib/python3.4/trace.py: option -h not recognized
Try `/usr/lib/python3.4/trace.py --help' for more information

$ python -mtrace --help
Usage: /usr/lib/python3.4/trace.py [OPTIONS] <file> [ARGS]
<help elided>

@anntzer anntzer mannequin added the stdlib Python modules in the Lib dir label Jul 16, 2015
@bitdancer
Copy link
Member

Please open individual issues to address individual modules that you would like to contribute to improving. Adding/fixing help is often best done by rewriting the argument parsing...contributions have been made to improve several modules already. In most cases we don't have tests for the -m features, and those need to be created first. In some cases we don't really want to continue to support whatever -m code exists (because it exists for no-longer-relevant historical reasons...though that doesn't apply in the two cases you reference). So each module needs to be addressed individually.

To address the specific issue you raise: I believe that when we have rewritten things, we have chosen to follow argparse's lead and support both -h and --help for the display of help information.

@anntzer
Copy link
Mannequin Author

anntzer mannequin commented Jul 16, 2015

To be honest I don't really plan to contribute any patch on this specific issue right now, the CLI interface of e.g. trace has some other serious issues (see e.g. bpo-24649) that I don't want to work out, and writing tests for the CLI are a pain too (also why I haven't made more progress on bpo-23596).

@bitdancer
Copy link
Member

Yes, that's pretty much why things are in the state they are in ;)

Still, opening individual issues for help problems with individual modules is the way to go, as you did (thank you).

@ezio-melotti
Copy link
Member

writing tests for the CLI are a pain too

It shouldn't be particularly difficult to do it using script_helper.assert_python_{ok|failure}(), even though you could also check the argument /parsing/ separately without having to launch a subprocess.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

2 participants