-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
Add colour to argparse help #130645
Copy link
Copy link
Closed
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement
Projects
Status
Doc issues
Feature or enhancement
In Python 3.13 we added colour output to the new REPL,
tracebackanddoctest, and in 3.14 tounittest,test.regrtestandcalendar, that can also be controlled with thePYTHON_COLORS,NO_COLORandFORCE_COLORenvironment variables:Let's add colour to
argparsehelp output.Survey
First, here's a survey of some other CLIs that use colour:
Survey
See also: bat, hyperfine, oxipng, zizmor
These fall into four groups:
Prototypes
I've made prototypes of two of these (uv/cargo style, typer/rich-cli style), and another with blue + magenta similar to the 3.13 REPL/traceback.
Prototypes
I think I prefer the typer/rich-cli style: the extra colour makes it easier to pick out the (green) short options from the (cyan) long options, and from their (green) arguments. And it should also be somewhat familiar to Python users who have used typer-based CLIs.
Linked PRs
argparsehelp #132323