| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
| #if defined(MS_WINDOWS) && defined(HAVE_WINDOWS_CONSOLE_IO) | ||
| { | ||
| DWORD mode = 0; | ||
| HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE); |
There was a problem hiding this comment.
Shouldn't this also consider stderr (or maybe it does? I don't know Windows quirks).
Sorry, something went wrong.
There was a problem hiding this comment.
Something like 294d008?
Sorry, something went wrong.
| PyMem_RawFree(buf); | ||
| } | ||
| else { | ||
| fprintf(f, usage_line, program); |
There was a problem hiding this comment.
If PyMem_RawMalloc fails we will get the raw tags, no?
Sorry, something went wrong.
There was a problem hiding this comment.
This now falls back to no tags.
Sorry, something went wrong.
| return; | ||
| } | ||
| } | ||
| fprint_tagged(stdout, usage_envvars, 0); |
There was a problem hiding this comment.
We still need formatting here?
Sorry, something went wrong.
There was a problem hiding this comment.
Yes, updated to use colour if available.
Sorry, something went wrong.
There was a problem hiding this comment.
What if the program path by accident contains {E}?
Sorry, something went wrong.
|
Updated to flip it: colour codes are now included in the help text (via macros to keep it tidier), and stripped out when not needed. So {E} in the path is not an issue. |
Sorry, something went wrong.
|
Thanks for the reviews, any further comments? |
Sorry, something went wrong.
|
Would something like this be more maintainable? #define RESET "\x1b[0m"
#define ENVVAR(STR) "\x1b[1;36m" STR RESET |
Sorry, something went wrong.
|
Nice idea, updated :) |
Sorry, something went wrong.
Documentation build overview5 files changed · ± 5 modified ± Modified |
Sorry, something went wrong.
|
This version is barely readable. What if return to the previous version with substitutions and use some of substitution codes to substitute the program name, the default PYTHONHOME, the path separator instead of just color sequences? |
Sorry, something went wrong.
| SHORTOPT("-d") " : turn on parser debugging output (for experts only, only works on\n" | ||
| " debug builds); also " ENVVAR_REF("PYTHONDEBUG") SUMMARY_LABEL("=x") "\n" | ||
| SHORTOPT("-E") " : ignore " ENVVAR_REF("PYTHON*") " environment variables (such as " ENVVAR_REF("PYTHONPATH") ")\n" | ||
| SHORTOPT("-h") " : print this help message and exit (also " SHORTOPT_SUMMARY("-?") " or " ENVVAR_REF("--help") ")\n" |
There was a problem hiding this comment.
| SHORTOPT("-h") " : print this help message and exit (also " SHORTOPT_SUMMARY("-?") " or " ENVVAR_REF("--help") ")\n" | |
| SHORTOPT("-h") " : print this help message and exit (also " SHORTOPT_SUMMARY("-?") " or " LONGOPT("--help") ")\n" |
Sorry, something went wrong.
| " this option has no effect on stdin; also " ENVVAR_REF("PYTHONUNBUFFERED") SUMMARY_LABEL("=x") "\n" | ||
| SHORTOPT("-v") " : verbose (trace import statements); also " ENVVAR_REF("PYTHONVERBOSE") SUMMARY_LABEL("=x") "\n" | ||
| " can be supplied multiple times to increase verbosity\n" | ||
| SHORTOPT("-V") " : print the Python version number and exit (also " ENVVAR_REF("--version") ")\n" |
There was a problem hiding this comment.
| SHORTOPT("-V") " : print the Python version number and exit (also " ENVVAR_REF("--version") ")\n" | |
| SHORTOPT("-V") " : print the Python version number and exit (also " LONGOPT("--version") ")\n" |
Sorry, something went wrong.
| "PYTHON_FROZEN_MODULES: whether to use frozen modules; the default is \"on\"\n" | ||
| " for installed Python and \"off\" for a local build\n" | ||
| " (-X frozen_modules)\n" | ||
| HEADING("These variables have equivalent command-line options (see ") ENVVAR_REF("--help") " for details):" "\n" |
There was a problem hiding this comment.
| HEADING("These variables have equivalent command-line options (see ") ENVVAR_REF("--help") " for details):" "\n" | |
| HEADING("These variables have equivalent command-line options") "(see " ENVVAR_REF("--help") " for details):" "\n" |
Sorry, something went wrong.
| "PYTHONPERFSUPPORT: support the Linux \"perf\" profiler (-X perf)\n" | ||
| ENVVAR("PYTHONINSPECT") " : inspect interactively after running script (" SHORTOPT_SUMMARY("-i") ")\n" | ||
| ENVVAR("PYTHONINTMAXSTRDIGITS") ": limit the size of int<->str conversions;\n" | ||
| " 0 disables the limit (" SHORTOPT_SUMMARY("-X") " " ENVVAR_REF("int_max_str_digits") SUMMARY_LABEL("=N") ")\n" |
There was a problem hiding this comment.
| " 0 disables the limit (" SHORTOPT_SUMMARY("-X") " " ENVVAR_REF("int_max_str_digits") SUMMARY_LABEL("=N") ")\n" | |
| " " SUMMARY_LABEL("0") " disables the limit (" SHORTOPT_SUMMARY("-X") " " ENVVAR_REF("int_max_str_digits") SUMMARY_LABEL("=N") ")\n" |
Sorry, something went wrong.
| ENVVAR("PYTHONEXECUTABLE") ": set sys.argv[0] to this value (macOS only)\n" | ||
| #endif | ||
| "PYTHONHASHSEED : if this variable is set to 'random', a random value is used\n" | ||
| ENVVAR("PYTHONHASHSEED") " : if this variable is set to 'random', a random value is used\n" |
There was a problem hiding this comment.
| ENVVAR("PYTHONHASHSEED") " : if this variable is set to 'random', a random value is used\n" | |
| ENVVAR("PYTHONHASHSEED") " : if this variable is set to '" SUMMARY_LABEL("random") "', a random value is used\n" |
Sorry, something went wrong.
| "PYTHONMALLOCSTATS: print memory allocator statistics\n" | ||
| "PYTHONPATH : '%lc'-separated list of directories prefixed to the\n" | ||
| ENVVAR("PYTHONMALLOCSTATS") ": print memory allocator statistics\n" | ||
| ENVVAR("PYTHONPATH") " : '%lc'-separated list of directories prefixed to the\n" |
There was a problem hiding this comment.
| ENVVAR("PYTHONPATH") " : '%lc'-separated list of directories prefixed to the\n" | |
| ENVVAR("PYTHONPATH") " : '" SUMMARY_LABEL(%lc) "'-separated list of directories prefixed to the\n" |
Sorry, something went wrong.
|
My previous comment was related to the version prior to the latest change, but I still thing that substitution-based approach would be clearer than macros-based. |
Sorry, something went wrong.
|
@serhiy-storchaka Could you give a short example of what you're thinking of? |
Sorry, something went wrong.
|
Simple example: "{E}PYTHONHOME{r} : alternate <prefix> directory (or <prefix>{b}{D}{r}<exec_prefix>).\n"
" The default module search path uses {b}{H}{r}.\n"{E}, {b} and {r} substitute color sequences, {D} substitutes the DELIM character, {H} substitutes PYTHONHOMEHELP. To avoid repeated {r} we can also change the syntax, for example: "#E{PYTHONHOME} : alternate <prefix> directory (or <prefix>#b{#D}<exec_prefix>).\n"
" The default module search path uses #b{#H}.\n"This is simpler than it looks. #E{ and #b{ change the color, } resets it to default. We do not need to support arbitrary nesting. |
Sorry, something went wrong.
|
Thanks, updated! How does this look? |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM. 👍
Sorry, something went wrong.
|
Thanks all for the reviews! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
python --help (and especially --help-all) is a monochrome wall of text. Similar to argparse help, let's add some colour to add structure and improve readability.
Here's real screenshots of --help and termshot capture of --help-all:
📚 Documentation preview 📚: https://cpython-previews--148767.org.readthedocs.build/