Title: Add colour to `argparse` help · Issue #130645 · python/cpython · GitHub
Open Graph Title: Add colour to `argparse` help · Issue #130645 · python/cpython
X Title: Add colour to `argparse` help · Issue #130645 · python/cpython
Description: Feature or enhancement In Python 3.13 we added colour output to the new REPL, traceback and doctest, and in 3.14 to unittest, test.regrtest and calendar, that can also be controlled with the PYTHON_COLORS, NO_COLOR and FORCE_COLOR enviro...
Open Graph Description: Feature or enhancement In Python 3.13 we added colour output to the new REPL, traceback and doctest, and in 3.14 to unittest, test.regrtest and calendar, that can also be controlled with the PYTHON...
X Description: Feature or enhancement In Python 3.13 we added colour output to the new REPL, traceback and doctest, and in 3.14 to unittest, test.regrtest and calendar, that can also be controlled with the PYTHON...
Opengraph URL: https://github.com/python/cpython/issues/130645
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add colour to `argparse` help","articleBody":"# Feature or enhancement\n\nIn Python 3.13 we added colour output to the new REPL, `traceback` and `doctest`, and in 3.14 to `unittest`, `test.regrtest` and `calendar`, that can also be controlled with the `PYTHON_COLORS`, `NO_COLOR` and `FORCE_COLOR` environment variables:\n\n* https://docs.python.org/3.14/whatsnew/3.14.html#unittest\n* https://docs.python.org/3.14/using/cmdline.html#using-on-controlling-color\n\nLet's add colour to `argparse` help output.\n\n## Survey\n\nFirst, here's a survey of some other CLIs that use colour:\n\n\u003cdetails\u003e\n\u003csummary\u003eSurvey\u003c/summary\u003e\n\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth colspan=2\u003euv\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cimg width=\"868\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/31869566-6580-4035-b1f4-d5695b77cfb1\" /\u003e\n\u003ctd\u003e\u003cimg width=\"871\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/eea6349f-9590-4d2e-8cbe-9c0f27784cac\" /\u003e\n\n\u003ctr\u003e\n\u003cth colspan=2\u003ecargo\n\n\u003ctr\u003e\n\u003ctd\u003e\u003cimg width=\"864\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/3b6834c1-ca9d-4c97-a8c5-e9af660a8144\" /\u003e\n\u003ctd\u003e\u003cimg width=\"871\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/b4722fca-1610-407e-8672-604e3de2baf5\" /\u003e\n\n\u003ctr\u003e\n\u003cth colspan=2\u003ecomposer\n\n\u003ctr\u003e\n\u003ctd\u003e\u003cimg width=\"864\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/ad691d30-918e-4f88-8ae0-ca5fc2bbd7d6\" /\u003e\n\u003ctd\u003e\u003cimg width=\"871\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/fcb522cc-b6a8-47c4-b784-d121b7acff3e\" /\u003e\n\n\u003ctr\u003e\n\u003cth colspan=2\u003eruff\n\n\u003ctr\u003e\n\u003ctd\u003e\u003cimg width=\"864\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/42a962c3-33d9-4fa1-aa35-1ba5a55f650a\" /\u003e\n\u003ctd\u003e\u003cimg width=\"871\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/89f997ee-0a18-49f5-9039-1a5634503d90\" /\u003e\n\n\u003ctr\u003e\n\u003cth colspan=2\u003elsd\n\n\u003ctr\u003e\n\u003ctd\u003e\u003cimg width=\"868\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/03ad0675-1845-43aa-8802-fb6f3edf6d99\" /\u003e\n\u003ctd\u003e\u003cimg width=\"871\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/96b8b582-d40d-4a4e-be51-a04abb15c357\" /\u003e\n\n\u003ctr\u003e\n\u003cth colspan=2\u003efd\n\n\u003ctr\u003e\n\u003ctd\u003e\u003cimg width=\"868\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/cd5caa47-fbda-47f8-841b-c3386534e8e4\" /\u003e\n\u003ctd\u003e\u003cimg width=\"871\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/c4eac0cf-b46d-478f-8604-86d666109e17\" /\u003e\n\nSee also: bat, hyperfine, oxipng, zizmor\n\n\u003ctr\u003e\n\u003cth colspan=2\u003egh\n\n\u003ctr\u003e\n\u003ctd\u003e\u003cimg width=\"868\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/10be9e0e-3712-4ae5-98c5-7b2dcfe91908\" /\u003e\n\u003ctd\u003e\u003cimg width=\"871\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/2ef5971b-c322-440c-8179-08cce3b78b76\" /\u003e\n\n\u003ctr\u003e\n\u003cth colspan=2\u003erich-cli\n\n\u003ctr\u003e\n\u003ctd\u003e\u003cimg width=\"864\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/4e7dae32-2992-419f-9ddc-92ae735ec3b9\" /\u003e\n\u003ctd\u003e\u003cimg width=\"871\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/abd1bebe-2dcf-4299-9295-de8da11a2500\" /\u003e\n\n\u003ctr\u003e\n\u003cth colspan=2\u003etyper\n\n\u003ctr\u003e\n\u003ctd\u003e\u003cimg width=\"864\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/e32d0e16-8e2b-4597-97f2-43d9cdbd482f\" /\u003e\n\u003ctd\u003e\u003cimg width=\"871\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/135643a7-7a1a-4786-ab96-3a2d69393b27\" /\u003e\n\n\u003c/table\u003e\n\n\n\u003c/details\u003e\n\nThese fall into four groups:\n\n* uv/cargo: green + cyan\n* composer: yellow + green\n* ruff/lsd/fd/gh: only bold\n* typer/rich-cli: green + cyan + yellow\n\n## Prototypes\n\nI'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.\n\n\u003cdetails\u003e\n\u003csummary\u003ePrototypes\u003c/summary\u003e\n\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth colspan=2\u003emain\n\u003ctr\u003e\n\u003ctd\u003e\u003cimg width=\"864\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/20be44cc-ae36-49d1-9911-3b4a0d6ddee6\" /\u003e\n\u003ctd\u003e\u003cimg width=\"871\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/35bfe5e9-5985-4db1-bfe4-a06f0bcf999e\" /\u003e\n\n\n\u003ctr\u003e\n\u003cth colspan=2\u003euv/cargo style\n\u003ctr\u003e\n\u003ctd\u003e\u003cimg width=\"864\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/21e21ab2-3e22-46ae-a10a-dd3dcc6c194d\" /\u003e\n\u003ctd\u003e\u003cimg width=\"871\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/e896f6e0-7112-482a-adba-21f1fdaa6dc1\" /\u003e\n\n\u003ctr\u003e\n\u003cth colspan=2\u003etyper/rich-cli style\n\u003ctr\u003e\n\n\u003ctd\u003e\u003cimg width=\"864\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/a43c721b-0ad0-4087-b241-14bf86c96c9e\" /\u003e\n\u003ctd\u003e\u003cimg width=\"871\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/da4408e4-76c2-42c3-8fff-f1270c701d10\" /\u003e\n\n\u003ctr\u003e\n\u003cth colspan=2\u003eREPL style\n\u003ctr\u003e\n\u003ctd\u003e\u003cimg width=\"864\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/3feb9a82-dfa8-4d29-8613-713db857bd00\" /\u003e\n\u003ctd\u003e\u003cimg width=\"871\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/ab5cdf6a-47a3-413b-bdf1-2dc885dc4c9a\" /\u003e\n\n\u003c/table\u003e\n\n\u003c/details\u003e\n\n\nI 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.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-132323\n* gh-133380\n* gh-136809\n* gh-136886\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/hugovk","@type":"Person","name":"hugovk"},"datePublished":"2025-02-27T16:41:10.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/130645/cpython/issues/130645"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2d6c995c-0a88-6da4-06ac-08de60e90cc0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9DD0:69848:92073C:C7D30C:696E80FF |
| html-safe-nonce | 15a913a7f44b080105fb04cb90169e8299808988655f9632ad64751ef9acef31 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5REQwOjY5ODQ4OjkyMDczQzpDN0QzMEM6Njk2RTgwRkYiLCJ2aXNpdG9yX2lkIjoiNDE5MTM4MzkyNjUxODc0MzI5NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 833105d8699268d6b87dfd77882ef0908294dbe0e3cecfb0517dcce2d1e0b1a6 |
| hovercard-subject-tag | issue:2885049118 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/130645/issue_layout |
| twitter:image | https://opengraph.githubassets.com/58067db60adab968f45cfe9f1df89aec8b0cca1655445eb6ef8bda8329cacd93/python/cpython/issues/130645 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/58067db60adab968f45cfe9f1df89aec8b0cca1655445eb6ef8bda8329cacd93/python/cpython/issues/130645 |
| og:image:alt | Feature or enhancement In Python 3.13 we added colour output to the new REPL, traceback and doctest, and in 3.14 to unittest, test.regrtest and calendar, that can also be controlled with the PYTHON... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hugovk |
| hostname | github.com |
| expected-hostname | github.com |
| None | fdad15fd2ad43212aa8b8be5f2c2725550f8374ceeeb154a999ad9145b43f3f7 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 27b23bc056eb973d350fc95afc848757edb9e7a9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width