-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
gh-90300: split --help output into separate options #30331
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
Changes from 1 commit
225c869
eaefd1a
57fd33b
55dbf69
0aaf9af
a592003
1c4cf63
d8bfcff
38f2dd8
a828fe8
8bde4ec
0dbaf03
0c9a995
aab464f
064d4ad
b9a0b19
0ee24d4
dd2beaa
c74fc69
2f108fe
4f345e8
a6573d6
da97a38
98525b4
5585095
24526bd
0bb5dfa
8fa72f5
29d04a0
356d1bf
ac1b5fb
9bcea95
5485255
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
Make ``--help`` output shorter by moving some info to the new | ||
``--help-env`` and ``-X help`` options. | ||
``--help-env`` and ``--help-xoptions`` command-line options. |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -40,6 +40,8 @@ Options (and corresponding environment variables):\n\ | |||||
debug builds); also PYTHONDEBUG=x\n\ | ||||||
-E : ignore PYTHON* environment variables (such as PYTHONPATH)\n\ | ||||||
-h : print this help message and exit (also --help)\n\ | ||||||
--help-env : print help about Python-specific environment variables and exit\n\ | ||||||
merwok marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
--help-xoptions : print help about implementation-specific -X options and exit\n\ | ||||||
"; | ||||||
static const char usage_2[] = "\ | ||||||
ericsnowcurrently marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
-i : inspect interactively after running script; forces a prompt even\n\ | ||||||
|
@@ -64,8 +66,7 @@ static const char usage_3[] = "\ | |||||
-W arg : warning control; arg is action:message:category:module:lineno\n\ | ||||||
also PYTHONWARNINGS=arg\n\ | ||||||
-x : skip first line of source, allowing use of non-Unix forms of #!cmd\n\ | ||||||
-X opt : set implementation-specific option (see details with -X help)\n\ | ||||||
--help-env : print help about Python-specific environment variables\n\ | ||||||
-X opt : set implementation-specific option\n\ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I’ve added it and removed it. In the current version, I think it is not needed, as it is a few lines later and in the man page and shown in error message for unknown X option, but have no problem adding it if someone adds 👍🏽 to your comment 🙂 |
||||||
--check-hash-based-pycs always|default|never :\n\ | ||||||
control how Python invalidates hash-based .pyc files\n\ | ||||||
"; | ||||||
|
@@ -78,7 +79,6 @@ arg ...: arguments passed to program in sys.argv[1:]\n\ | |||||
|
||||||
static const char usage_xoptions[] = "\ | ||||||
merwok marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
The following implementation-specific options are available:\n\ | ||||||
-X help: show this help and exit\n\ | ||||||
-X faulthandler: enable faulthandler\n\ | ||||||
-X showrefcount: output the total reference count and number of used\n\ | ||||||
memory blocks when the program finishes or after each statement in the\n\ | ||||||
|
@@ -2028,7 +2028,6 @@ _PyConfig_InitImportConfig(PyConfig *config) | |||||
// set, like -X showrefcount which requires a debug build. In this case unknown | ||||||
// options are silently ignored. | ||||||
const wchar_t* known_xoptions[] = { | ||||||
L"help", | ||||||
L"faulthandler", | ||||||
L"showrefcount", | ||||||
L"tracemalloc", | ||||||
|
@@ -2084,7 +2083,7 @@ config_read(PyConfig *config, int compute_path_config) | |||||
/* -X options */ | ||||||
const wchar_t* option = _Py_check_xoptions(&config->xoptions, known_xoptions); | ||||||
if (option != NULL) { | ||||||
return PyStatus_Error("Unknown value for option -X (see -X help)"); | ||||||
return PyStatus_Error("Unknown value for option -X (see --help-xoptions)"); | ||||||
} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Turns out that showing the invalid value in this error message is not trivial: real C programmers had issue with it too before #28823 |
||||||
|
||||||
if (config_get_xoption(config, L"showrefcount")) { | ||||||
|
@@ -2271,7 +2270,6 @@ config_parse_cmdline(PyConfig *config, PyWideStringList *warnoptions, | |||||
const PyWideStringList *argv = &config->argv; | ||||||
int print_version = 0; | ||||||
const wchar_t* program = config->program_name; | ||||||
const wchar_t* xoption_help; | ||||||
|
||||||
_PyOS_ResetGetOpt(); | ||||||
do { | ||||||
|
@@ -2338,6 +2336,11 @@ config_parse_cmdline(PyConfig *config, PyWideStringList *warnoptions, | |||||
config_envvars_usage(); | ||||||
return _PyStatus_EXIT(0); | ||||||
|
||||||
case 2: | ||||||
// help-xoptions | ||||||
config_xoptions_usage(); | ||||||
return _PyStatus_EXIT(0); | ||||||
|
||||||
case 'b': | ||||||
config->bytes_warning++; | ||||||
break; | ||||||
|
@@ -2353,6 +2356,7 @@ config_parse_cmdline(PyConfig *config, PyWideStringList *warnoptions, | |||||
|
||||||
case 'E': | ||||||
case 'I': | ||||||
case 'X': | ||||||
/* option handled by _PyPreCmdline_Read() */ | ||||||
break; | ||||||
|
||||||
|
@@ -2414,15 +2418,6 @@ config_parse_cmdline(PyConfig *config, PyWideStringList *warnoptions, | |||||
config->use_hash_seed = 0; | ||||||
break; | ||||||
|
||||||
case 'X': | ||||||
xoption_help = config_get_xoption(config, L"help"); | ||||||
if (xoption_help) { | ||||||
52FE config_xoptions_usage(); | ||||||
return _PyStatus_EXIT(0); | ||||||
} | ||||||
/* option handled by _PyPreCmdline_Read() */ | ||||||
break; | ||||||
|
||||||
/* This space reserved for other options */ | ||||||
|
||||||
default: | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought showing all help options on their own line could be nice.