assignee=Noneclosed_at=Nonecreated_at=<Date2021-12-20.23:43:15.950>labels= ['interpreter-core', 'type-feature', '3.11']
title='python --help output is too long'updated_at=<Date2022-01-12.01:45:18.299>user='https://github.com/merwok'
The output of "python -h" is 104 lines long now. It was only 51 lines in
3.6. 35% of it is about the -X option, and 30% about environment
variables. Also some lines in the -X option description are too long
(102 columns). Both topics are "advanced" and mostly interested for
debugging. I suggest to move them out of the main help output. […]
Guido:
-X opt : implementation-specific option; use -X help to list options.
We could also see if we can put the help text for each of the supported -X
flags in the table defining these flags […]
GvR again:
--help-env […] prints info about env vars (new flag)
I would enjoy trying to make a patch around next week!
Question about the implementation:
I’ve found the parsing of command-line params in Python/initconfig.c and Python/preconfig.c.
Help is handled in initconfig, X options in preconfig.
A) could add a value to the right struct for "-X help", set it in preconfig, handle it in initconfig (by printing X options help and exiting, maybe reusing the existing print help function or writing a very similar one next to it)
B) or detect the option in preconfig, print and exit right there
It seems that preconfig is only for some options that change fundamental behaviour (isolated mode, default encoding), so I should be able to detect and handle '-X help' in initconfig.
Victor said on github that he would prefer --help-xoptions to -X help. It would align with --help and --help-env, but not with other -X abc options. I think that --help-X may be better, as it uses the same form (X) rather than the non-word xoptions.
Activity
merwok commented on Dec 20, 2021
From Serhiy in https://mail.python.org/archives/list/python-dev@python.org/thread/QUUBM7DGSXYWBOLZNWOSCQUDALWJIYZF/ :
Guido:
GvR again:
I would enjoy trying to make a patch around next week!
merwok commented on Dec 20, 2021
Forgot to quote -X help to print help about X options.
merwok commented on Jan 1, 2022
Do people think the man page should be shortened too?
serhiy-storchaka commented on Jan 1, 2022
I think that the man page should contain all details related to the CLI (and may be even some examples).
merwok commented on Jan 1, 2022
Question about the implementation:
I’ve found the parsing of command-line params in Python/initconfig.c and Python/preconfig.c.
Help is handled in initconfig, X options in preconfig.
A) could add a value to the right struct for "-X help", set it in preconfig, handle it in initconfig (by printing X options help and exiting, maybe reusing the existing print help function or writing a very similar one next to it)
B) or detect the option in preconfig, print and exit right there
Which option is best?
merwok commented on Jan 2, 2022
It seems that preconfig is only for some options that change fundamental behaviour (isolated mode, default encoding), so I should be able to detect and handle '-X help' in initconfig.
vstinner commented on Jan 5, 2022
initconfig.c parses all -X options. preconfig.c also checks for a few specific -X options which are also checked in initconfig.c.
My notes on parsing command line options:
https://pythondev.readthedocs.io/pyconfig.html#add-a-new-command-line-option
merwok commented on Jan 6, 2022
Victor said on github that he would prefer --help-xoptions to -X help. It would align with --help and --help-env, but not with other -X abc options. I think that --help-X may be better, as it uses the same form (X) rather than the non-word xoptions.
What do people think?
vstinner commented on Jan 6, 2022
"xoptions" name comes from sys._xoptions (Python) and PyConfig.xoptions (C). Oh, sys._xoptions is a private API... but it's mentioned in the -X documentation:
https://docs.python.org/3/using/cmdline.html#cmdoption-X
68 remaining items
pythongh-90300: Document equivalent -X options for envvars in the Pyt…
pythongh-90300: Fix undocumented envvars in the Python CLI help (pyth…
pythongh-90300: Improve the Python CLI help output (pythonGH-115853)
pythongh-90300: Fix cmdline.rst (pythonGH-116721)
pythongh-90300: Sort the -X options and some envvars in the Python CL…
pythongh-90300: Document equivalent -X options for envvars in the Pyt…
pythongh-90300: Fix undocumented envvars in the Python CLI help (pyth…
pythongh-90300: Improve the Python CLI help output (pythonGH-115853)
pythongh-90300: Reformat the Python CLI help output (pythonGH-93415)
pythongh-90300: Fix cmdline.rst (pythonGH-116721)
pythongh-90300: Sort the -X options and some envvars in the Python CL…
pythongh-90300: Document equivalent -X options for envvars in the Pyt…
pythongh-90300: Fix undocumented envvars in the Python CLI help (pyth…
pythongh-90300: Improve the Python CLI help output (pythonGH-115853)
pythongh-90300: Reformat the Python CLI help output (pythonGH-93415)