[{"data":1,"prerenderedAt":2819},["ShallowReactive",2],{"page-\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Ftheming-rich-output-consistently\u002F":3,"content-directory":2272},{"id":4,"title":5,"body":6,"date":2257,"description":2258,"difficulty":2259,"draft":2260,"extension":2261,"meta":2262,"navigation":157,"path":2263,"seo":2264,"stem":2265,"tags":2266,"updated":2257,"__hash__":2271},"content\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Ftheming-rich-output-consistently\u002Findex.md","Theming Rich Output Consistently in Python CLIs",{"type":7,"value":8,"toc":2238},"minimark",[9,67,72,85,89,93,112,116,1129,1132,1359,1364,1375,1398,1412,1420,1430,1434,1437,1440,1485,1492,1496,1499,1548,1552,1559,2114,2124,2128,2134,2138,2142,2149,2153,2156,2160,2175,2179,2188,2192,2199,2203,2234],[10,11,12,13,17,18,21,22,25,26,29,30,34,35,38,39,38,42,45,46,49,50,53,54,57,58,60,61,66],"p",{},"After a few months of development, most CLIs using Rich have accumulated a colour palette nobody chose: ",[14,15,16],"code",{},"[red]"," in one command and ",[14,19,20],{},"[bold red]"," in another for the same kind of error, ",[14,23,24],{},"[green]"," successes next to ",[14,27,28],{},"[bright_green]"," ones, a dim grey that is unreadable on light terminal themes, blue text that vanishes on dark ones, and a check mark in some success messages but not others. Users stop being able to read the output at a glance, because the same colour means different things in different places. The fix is the same one web developers use: ",[31,32,33],"strong",{},"semantic styles",". Define what ",[14,36,37],{},"success",", ",[14,40,41],{},"warning",[14,43,44],{},"error"," and ",[14,47,48],{},"muted"," look like once, in a Rich ",[14,51,52],{},"Theme","; write ",[14,55,56],{},"[error]"," instead of ",[14,59,16],{}," everywhere; and route messages through a tiny helper so the format of each kind of message is consistent too. This guide builds that, chooses a palette that survives light and dark themes, lets users override it from their config, and tests it. It belongs to the ",[62,63,65],"a",{"href":64},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002F","interactive terminal UI with Rich topic",".",[68,69,71],"h2",{"id":70},"prerequisites","Prerequisites",[73,74,75,82],"ul",{},[76,77,78,79,66],"li",{},"Rich 13+ (included with Typer) and Python 3.11+ for ",[14,80,81],{},"tomllib",[76,83,84],{},"A CLI with more than a couple of commands producing styled output.",[68,86,88],{"id":87},"semantic-styles-not-colours","Semantic styles, not colours",[90,91],"inline-diagram",{"name":92},"th-semantic",[10,94,95,96,98,99,102,103,106,107,111],{},"A Rich ",[14,97,52],{}," maps style ",[31,100,101],{},"names"," to style definitions. Once a console has the theme, markup like ",[14,104,105],{},"[error]...[\u002F]"," uses the named style. The code now says what a piece of text ",[108,109,110],"em",{},"means"," — this is an error, this is secondary detail, this is a path — and the theme decides what that looks like. Changing the error colour becomes a one-line edit, users can override styles in their own config, and every command automatically agrees with every other.",[68,113,115],{"id":114},"the-recipe","The recipe",[117,118,123],"pre",{"className":119,"code":120,"language":121,"meta":122,"style":122},"language-python shiki shiki-themes github-light github-dark","# src\u002Fmytool\u002Ftheme.py\nfrom __future__ import annotations\n\nimport tomllib\nfrom pathlib import Path\n\nfrom rich.console import Console\nfrom rich.errors import StyleSyntaxError\nfrom rich.style import Style\nfrom rich.theme import Theme\n\nDEFAULT_STYLES: dict[str, str] = {\n    \"success\": \"green\",\n    \"warning\": \"yellow\",\n    \"error\": \"bold red\",\n    \"muted\": \"dim\",\n    \"heading\": \"bold\",\n    \"code\": \"cyan\",\n    \"path\": \"underline\",\n}\nSYMBOLS = {\"success\": \"✓\", \"warning\": \"!\", \"error\": \"✗\"}\n\n\ndef load_theme(user_file: Path | None = None) -> Theme:\n    \"\"\"Defaults, overridden per key by an optional [theme] table in the user's config.\"\"\"\n    styles = dict(DEFAULT_STYLES)\n    if user_file and user_file.is_file():\n        with user_file.open(\"rb\") as fh:\n            overrides = tomllib.load(fh).get(\"theme\", {})\n        for name, value in overrides.items():\n            if name not in DEFAULT_STYLES:\n                raise ValueError(f\"unknown style {name!r}; known: {', '.join(DEFAULT_STYLES)}\")\n            try:\n                Style.parse(value)\n            except StyleSyntaxError as exc:\n                raise ValueError(f\"invalid style for {name!r}: {exc}\") from None\n            styles[name] = value\n    return Theme(styles, inherit=True)\n\n\ndef make_console(theme: Theme, *, stderr: bool = False, **kwargs) -> Console:\n    return Console(theme=theme, stderr=stderr, highlight=False, **kwargs)\n\n\nclass Out:\n    \"\"\"The only way commands produce styled messages.\"\"\"\n\n    def __init__(self, console: Console) -> None:\n        self.console = console\n\n    def success(self, text: str) -> None:\n        self.console.print(f\"[success]{SYMBOLS['success']}[\u002F] {text}\")\n\n    def warning(self, text: str) -> None:\n        self.console.print(f\"[warning]{SYMBOLS['warning']}[\u002F] {text}\")\n\n    def error(self, text: str, hint: str | None = None) -> None:\n        self.console.print(f\"[error]{SYMBOLS['error']} {text}[\u002F]\")\n        if hint:\n            self.console.print(f\"  [muted]hint:[\u002F] {hint}\")\n\n    def detail(self, text: str) -> None:\n        self.console.print(f\"  [muted]{text}[\u002F]\")\n","python","",[14,124,125,134,152,159,168,181,186,199,212,225,238,243,268,284,297,310,323,336,349,362,368,410,415,420,446,452,471,486,507,524,539,560,612,620,626,640,680,691,711,716,721,754,793,798,803,814,820,825,842,856,861,881,922,927,945,980,985,1017,1051,1060,1084,1089,1107],{"__ignoreMap":122},[126,127,130],"span",{"class":128,"line":129},"line",1,[126,131,133],{"class":132},"sJ8bj","# src\u002Fmytool\u002Ftheme.py\n",[126,135,137,141,145,148],{"class":128,"line":136},2,[126,138,140],{"class":139},"szBVR","from",[126,142,144],{"class":143},"sj4cs"," __future__",[126,146,147],{"class":139}," import",[126,149,151],{"class":150},"sVt8B"," annotations\n",[126,153,155],{"class":128,"line":154},3,[126,156,158],{"emptyLinePlaceholder":157},true,"\n",[126,160,162,165],{"class":128,"line":161},4,[126,163,164],{"class":139},"import",[126,166,167],{"class":150}," tomllib\n",[126,169,171,173,176,178],{"class":128,"line":170},5,[126,172,140],{"class":139},[126,174,175],{"class":150}," pathlib ",[126,177,164],{"class":139},[126,179,180],{"class":150}," Path\n",[126,182,184],{"class":128,"line":183},6,[126,185,158],{"emptyLinePlaceholder":157},[126,187,189,191,194,196],{"class":128,"line":188},7,[126,190,140],{"class":139},[126,192,193],{"class":150}," rich.console ",[126,195,164],{"class":139},[126,197,198],{"class":150}," Console\n",[126,200,202,204,207,209],{"class":128,"line":201},8,[126,203,140],{"class":139},[126,205,206],{"class":150}," rich.errors ",[126,208,164],{"class":139},[126,210,211],{"class":150}," StyleSyntaxError\n",[126,213,215,217,220,222],{"class":128,"line":214},9,[126,216,140],{"class":139},[126,218,219],{"class":150}," rich.style ",[126,221,164],{"class":139},[126,223,224],{"class":150}," Style\n",[126,226,228,230,233,235],{"class":128,"line":227},10,[126,229,140],{"class":139},[126,231,232],{"class":150}," rich.theme ",[126,234,164],{"class":139},[126,236,237],{"class":150}," Theme\n",[126,239,241],{"class":128,"line":240},11,[126,242,158],{"emptyLinePlaceholder":157},[126,244,246,249,252,255,257,259,262,265],{"class":128,"line":245},12,[126,247,248],{"class":143},"DEFAULT_STYLES",[126,250,251],{"class":150},": dict[",[126,253,254],{"class":143},"str",[126,256,38],{"class":150},[126,258,254],{"class":143},[126,260,261],{"class":150},"] ",[126,263,264],{"class":139},"=",[126,266,267],{"class":150}," {\n",[126,269,271,275,278,281],{"class":128,"line":270},13,[126,272,274],{"class":273},"sZZnC","    \"success\"",[126,276,277],{"class":150},": ",[126,279,280],{"class":273},"\"green\"",[126,282,283],{"class":150},",\n",[126,285,287,290,292,295],{"class":128,"line":286},14,[126,288,289],{"class":273},"    \"warning\"",[126,291,277],{"class":150},[126,293,294],{"class":273},"\"yellow\"",[126,296,283],{"class":150},[126,298,300,303,305,308],{"class":128,"line":299},15,[126,301,302],{"class":273},"    \"error\"",[126,304,277],{"class":150},[126,306,307],{"class":273},"\"bold red\"",[126,309,283],{"class":150},[126,311,313,316,318,321],{"class":128,"line":312},16,[126,314,315],{"class":273},"    \"muted\"",[126,317,277],{"class":150},[126,319,320],{"class":273},"\"dim\"",[126,322,283],{"class":150},[126,324,326,329,331,334],{"class":128,"line":325},17,[126,327,328],{"class":273},"    \"heading\"",[126,330,277],{"class":150},[126,332,333],{"class":273},"\"bold\"",[126,335,283],{"class":150},[126,337,339,342,344,347],{"class":128,"line":338},18,[126,340,341],{"class":273},"    \"code\"",[126,343,277],{"class":150},[126,345,346],{"class":273},"\"cyan\"",[126,348,283],{"class":150},[126,350,352,355,357,360],{"class":128,"line":351},19,[126,353,354],{"class":273},"    \"path\"",[126,356,277],{"class":150},[126,358,359],{"class":273},"\"underline\"",[126,361,283],{"class":150},[126,363,365],{"class":128,"line":364},20,[126,366,367],{"class":150},"}\n",[126,369,371,374,377,380,383,385,388,390,393,395,398,400,403,405,408],{"class":128,"line":370},21,[126,372,373],{"class":143},"SYMBOLS",[126,375,376],{"class":139}," =",[126,378,379],{"class":150}," {",[126,381,382],{"class":273},"\"success\"",[126,384,277],{"class":150},[126,386,387],{"class":273},"\"✓\"",[126,389,38],{"class":150},[126,391,392],{"class":273},"\"warning\"",[126,394,277],{"class":150},[126,396,397],{"class":273},"\"!\"",[126,399,38],{"class":150},[126,401,402],{"class":273},"\"error\"",[126,404,277],{"class":150},[126,406,407],{"class":273},"\"✗\"",[126,409,367],{"class":150},[126,411,413],{"class":128,"line":412},22,[126,414,158],{"emptyLinePlaceholder":157},[126,416,418],{"class":128,"line":417},23,[126,419,158],{"emptyLinePlaceholder":157},[126,421,423,426,430,433,436,439,441,443],{"class":128,"line":422},24,[126,424,425],{"class":139},"def",[126,427,429],{"class":428},"sScJk"," load_theme",[126,431,432],{"class":150},"(user_file: Path ",[126,434,435],{"class":139},"|",[126,437,438],{"class":143}," None",[126,440,376],{"class":139},[126,442,438],{"class":143},[126,444,445],{"class":150},") -> Theme:\n",[126,447,449],{"class":128,"line":448},25,[126,450,451],{"class":273},"    \"\"\"Defaults, overridden per key by an optional [theme] table in the user's config.\"\"\"\n",[126,453,455,458,460,463,466,468],{"class":128,"line":454},26,[126,456,457],{"class":150},"    styles ",[126,459,264],{"class":139},[126,461,462],{"class":143}," dict",[126,464,465],{"class":150},"(",[126,467,248],{"class":143},[126,469,470],{"class":150},")\n",[126,472,474,477,480,483],{"class":128,"line":473},27,[126,475,476],{"class":139},"    if",[126,478,479],{"class":150}," user_file ",[126,481,482],{"class":139},"and",[126,484,485],{"class":150}," user_file.is_file():\n",[126,487,489,492,495,498,501,504],{"class":128,"line":488},28,[126,490,491],{"class":139},"        with",[126,493,494],{"class":150}," user_file.open(",[126,496,497],{"class":273},"\"rb\"",[126,499,500],{"class":150},") ",[126,502,503],{"class":139},"as",[126,505,506],{"class":150}," fh:\n",[126,508,510,513,515,518,521],{"class":128,"line":509},29,[126,511,512],{"class":150},"            overrides ",[126,514,264],{"class":139},[126,516,517],{"class":150}," tomllib.load(fh).get(",[126,519,520],{"class":273},"\"theme\"",[126,522,523],{"class":150},", {})\n",[126,525,527,530,533,536],{"class":128,"line":526},30,[126,528,529],{"class":139},"        for",[126,531,532],{"class":150}," name, value ",[126,534,535],{"class":139},"in",[126,537,538],{"class":150}," overrides.items():\n",[126,540,542,545,548,551,554,557],{"class":128,"line":541},31,[126,543,544],{"class":139},"            if",[126,546,547],{"class":150}," name ",[126,549,550],{"class":139},"not",[126,552,553],{"class":139}," in",[126,555,556],{"class":143}," DEFAULT_STYLES",[126,558,559],{"class":150},":\n",[126,561,563,566,569,571,574,577,580,583,586,589,592,594,597,600,602,605,607,610],{"class":128,"line":562},32,[126,564,565],{"class":139},"                raise",[126,567,568],{"class":143}," ValueError",[126,570,465],{"class":150},[126,572,573],{"class":139},"f",[126,575,576],{"class":273},"\"unknown style ",[126,578,579],{"class":143},"{",[126,581,582],{"class":150},"name",[126,584,585],{"class":139},"!r",[126,587,588],{"class":143},"}",[126,590,591],{"class":273},"; known: ",[126,593,579],{"class":143},[126,595,596],{"class":273},"', '",[126,598,599],{"class":150},".join(",[126,601,248],{"class":143},[126,603,604],{"class":150},")",[126,606,588],{"class":143},[126,608,609],{"class":273},"\"",[126,611,470],{"class":150},[126,613,615,618],{"class":128,"line":614},33,[126,616,617],{"class":139},"            try",[126,619,559],{"class":150},[126,621,623],{"class":128,"line":622},34,[126,624,625],{"class":150},"                Style.parse(value)\n",[126,627,629,632,635,637],{"class":128,"line":628},35,[126,630,631],{"class":139},"            except",[126,633,634],{"class":150}," StyleSyntaxError ",[126,636,503],{"class":139},[126,638,639],{"class":150}," exc:\n",[126,641,643,645,647,649,651,654,656,658,660,662,664,666,669,671,673,675,677],{"class":128,"line":642},36,[126,644,565],{"class":139},[126,646,568],{"class":143},[126,648,465],{"class":150},[126,650,573],{"class":139},[126,652,653],{"class":273},"\"invalid style for ",[126,655,579],{"class":143},[126,657,582],{"class":150},[126,659,585],{"class":139},[126,661,588],{"class":143},[126,663,277],{"class":273},[126,665,579],{"class":143},[126,667,668],{"class":150},"exc",[126,670,588],{"class":143},[126,672,609],{"class":273},[126,674,500],{"class":150},[126,676,140],{"class":139},[126,678,679],{"class":143}," None\n",[126,681,683,686,688],{"class":128,"line":682},37,[126,684,685],{"class":150},"            styles[name] ",[126,687,264],{"class":139},[126,689,690],{"class":150}," value\n",[126,692,694,697,700,704,706,709],{"class":128,"line":693},38,[126,695,696],{"class":139},"    return",[126,698,699],{"class":150}," Theme(styles, ",[126,701,703],{"class":702},"s4XuR","inherit",[126,705,264],{"class":139},[126,707,708],{"class":143},"True",[126,710,470],{"class":150},[126,712,714],{"class":128,"line":713},39,[126,715,158],{"emptyLinePlaceholder":157},[126,717,719],{"class":128,"line":718},40,[126,720,158],{"emptyLinePlaceholder":157},[126,722,724,726,729,732,735,738,741,743,746,748,751],{"class":128,"line":723},41,[126,725,425],{"class":139},[126,727,728],{"class":428}," make_console",[126,730,731],{"class":150},"(theme: Theme, ",[126,733,734],{"class":139},"*",[126,736,737],{"class":150},", stderr: ",[126,739,740],{"class":143},"bool",[126,742,376],{"class":139},[126,744,745],{"class":143}," False",[126,747,38],{"class":150},[126,749,750],{"class":139},"**",[126,752,753],{"class":150},"kwargs) -> Console:\n",[126,755,757,759,762,765,767,770,773,775,778,781,783,786,788,790],{"class":128,"line":756},42,[126,758,696],{"class":139},[126,760,761],{"class":150}," Console(",[126,763,764],{"class":702},"theme",[126,766,264],{"class":139},[126,768,769],{"class":150},"theme, ",[126,771,772],{"class":702},"stderr",[126,774,264],{"class":139},[126,776,777],{"class":150},"stderr, ",[126,779,780],{"class":702},"highlight",[126,782,264],{"class":139},[126,784,785],{"class":143},"False",[126,787,38],{"class":150},[126,789,750],{"class":139},[126,791,792],{"class":150},"kwargs)\n",[126,794,796],{"class":128,"line":795},43,[126,797,158],{"emptyLinePlaceholder":157},[126,799,801],{"class":128,"line":800},44,[126,802,158],{"emptyLinePlaceholder":157},[126,804,806,809,812],{"class":128,"line":805},45,[126,807,808],{"class":139},"class",[126,810,811],{"class":428}," Out",[126,813,559],{"class":150},[126,815,817],{"class":128,"line":816},46,[126,818,819],{"class":273},"    \"\"\"The only way commands produce styled messages.\"\"\"\n",[126,821,823],{"class":128,"line":822},47,[126,824,158],{"emptyLinePlaceholder":157},[126,826,828,831,834,837,840],{"class":128,"line":827},48,[126,829,830],{"class":139},"    def",[126,832,833],{"class":143}," __init__",[126,835,836],{"class":150},"(self, console: Console) -> ",[126,838,839],{"class":143},"None",[126,841,559],{"class":150},[126,843,845,848,851,853],{"class":128,"line":844},49,[126,846,847],{"class":143},"        self",[126,849,850],{"class":150},".console ",[126,852,264],{"class":139},[126,854,855],{"class":150}," console\n",[126,857,859],{"class":128,"line":858},50,[126,860,158],{"emptyLinePlaceholder":157},[126,862,864,866,869,872,874,877,879],{"class":128,"line":863},51,[126,865,830],{"class":139},[126,867,868],{"class":428}," success",[126,870,871],{"class":150},"(self, text: ",[126,873,254],{"class":143},[126,875,876],{"class":150},") -> ",[126,878,839],{"class":143},[126,880,559],{"class":150},[126,882,884,886,889,891,894,897,900,903,906,908,911,913,916,918,920],{"class":128,"line":883},52,[126,885,847],{"class":143},[126,887,888],{"class":150},".console.print(",[126,890,573],{"class":139},[126,892,893],{"class":273},"\"[success]",[126,895,896],{"class":143},"{SYMBOLS",[126,898,899],{"class":150},"[",[126,901,902],{"class":273},"'success'",[126,904,905],{"class":150},"]",[126,907,588],{"class":143},[126,909,910],{"class":273},"[\u002F] ",[126,912,579],{"class":143},[126,914,915],{"class":150},"text",[126,917,588],{"class":143},[126,919,609],{"class":273},[126,921,470],{"class":150},[126,923,925],{"class":128,"line":924},53,[126,926,158],{"emptyLinePlaceholder":157},[126,928,930,932,935,937,939,941,943],{"class":128,"line":929},54,[126,931,830],{"class":139},[126,933,934],{"class":428}," warning",[126,936,871],{"class":150},[126,938,254],{"class":143},[126,940,876],{"class":150},[126,942,839],{"class":143},[126,944,559],{"class":150},[126,946,948,950,952,954,957,959,961,964,966,968,970,972,974,976,978],{"class":128,"line":947},55,[126,949,847],{"class":143},[126,951,888],{"class":150},[126,953,573],{"class":139},[126,955,956],{"class":273},"\"[warning]",[126,958,896],{"class":143},[126,960,899],{"class":150},[126,962,963],{"class":273},"'warning'",[126,965,905],{"class":150},[126,967,588],{"class":143},[126,969,910],{"class":273},[126,971,579],{"class":143},[126,973,915],{"class":150},[126,975,588],{"class":143},[126,977,609],{"class":273},[126,979,470],{"class":150},[126,981,983],{"class":128,"line":982},56,[126,984,158],{"emptyLinePlaceholder":157},[126,986,988,990,993,995,997,1000,1002,1005,1007,1009,1011,1013,1015],{"class":128,"line":987},57,[126,989,830],{"class":139},[126,991,992],{"class":428}," error",[126,994,871],{"class":150},[126,996,254],{"class":143},[126,998,999],{"class":150},", hint: ",[126,1001,254],{"class":143},[126,1003,1004],{"class":139}," |",[126,1006,438],{"class":143},[126,1008,376],{"class":139},[126,1010,438],{"class":143},[126,1012,876],{"class":150},[126,1014,839],{"class":143},[126,1016,559],{"class":150},[126,1018,1020,1022,1024,1026,1029,1031,1033,1036,1038,1040,1042,1044,1046,1049],{"class":128,"line":1019},58,[126,1021,847],{"class":143},[126,1023,888],{"class":150},[126,1025,573],{"class":139},[126,1027,1028],{"class":273},"\"[error]",[126,1030,896],{"class":143},[126,1032,899],{"class":150},[126,1034,1035],{"class":273},"'error'",[126,1037,905],{"class":150},[126,1039,588],{"class":143},[126,1041,379],{"class":143},[126,1043,915],{"class":150},[126,1045,588],{"class":143},[126,1047,1048],{"class":273},"[\u002F]\"",[126,1050,470],{"class":150},[126,1052,1054,1057],{"class":128,"line":1053},59,[126,1055,1056],{"class":139},"        if",[126,1058,1059],{"class":150}," hint:\n",[126,1061,1063,1066,1068,1070,1073,1075,1078,1080,1082],{"class":128,"line":1062},60,[126,1064,1065],{"class":143},"            self",[126,1067,888],{"class":150},[126,1069,573],{"class":139},[126,1071,1072],{"class":273},"\"  [muted]hint:[\u002F] ",[126,1074,579],{"class":143},[126,1076,1077],{"class":150},"hint",[126,1079,588],{"class":143},[126,1081,609],{"class":273},[126,1083,470],{"class":150},[126,1085,1087],{"class":128,"line":1086},61,[126,1088,158],{"emptyLinePlaceholder":157},[126,1090,1092,1094,1097,1099,1101,1103,1105],{"class":128,"line":1091},62,[126,1093,830],{"class":139},[126,1095,1096],{"class":428}," detail",[126,1098,871],{"class":150},[126,1100,254],{"class":143},[126,1102,876],{"class":150},[126,1104,839],{"class":143},[126,1106,559],{"class":150},[126,1108,1110,1112,1114,1116,1119,1121,1123,1125,1127],{"class":128,"line":1109},63,[126,1111,847],{"class":143},[126,1113,888],{"class":150},[126,1115,573],{"class":139},[126,1117,1118],{"class":273},"\"  [muted]",[126,1120,579],{"class":143},[126,1122,915],{"class":150},[126,1124,588],{"class":143},[126,1126,1048],{"class":273},[126,1128,470],{"class":150},[10,1130,1131],{},"In a Typer app, build the theme and console once in the callback and share them:",[117,1133,1135],{"className":119,"code":1134,"language":121,"meta":122,"style":122},"import typer\n\nfrom mytool.theme import Out, load_theme, make_console\nfrom mytool.paths import CONFIG_FILE          # e.g. from platformdirs\n\napp = typer.Typer()\n\n\n@app.callback()\ndef main(ctx: typer.Context) -> None:\n    theme = load_theme(CONFIG_FILE)\n    ctx.obj = {\"out\": Out(make_console(theme)), \"err\": Out(make_console(theme, stderr=True))}\n\n\n@app.command()\ndef deploy(ctx: typer.Context, site: str) -> None:\n    out, err = ctx.obj[\"out\"], ctx.obj[\"err\"]\n    out.success(f\"deployed {site} to [path]prod[\u002F]\")\n    err.warning(\"2 files over 1 MB\")\n    err.detail(\"uploaded 14 files in 3.2s\")\n",[14,1136,1137,1144,1148,1160,1175,1179,1189,1193,1197,1205,1219,1234,1264,1268,1272,1279,1297,1317,1339,1349],{"__ignoreMap":122},[126,1138,1139,1141],{"class":128,"line":129},[126,1140,164],{"class":139},[126,1142,1143],{"class":150}," typer\n",[126,1145,1146],{"class":128,"line":136},[126,1147,158],{"emptyLinePlaceholder":157},[126,1149,1150,1152,1155,1157],{"class":128,"line":154},[126,1151,140],{"class":139},[126,1153,1154],{"class":150}," mytool.theme ",[126,1156,164],{"class":139},[126,1158,1159],{"class":150}," Out, load_theme, make_console\n",[126,1161,1162,1164,1167,1169,1172],{"class":128,"line":161},[126,1163,140],{"class":139},[126,1165,1166],{"class":150}," mytool.paths ",[126,1168,164],{"class":139},[126,1170,1171],{"class":143}," CONFIG_FILE",[126,1173,1174],{"class":132},"          # e.g. from platformdirs\n",[126,1176,1177],{"class":128,"line":170},[126,1178,158],{"emptyLinePlaceholder":157},[126,1180,1181,1184,1186],{"class":128,"line":183},[126,1182,1183],{"class":150},"app ",[126,1185,264],{"class":139},[126,1187,1188],{"class":150}," typer.Typer()\n",[126,1190,1191],{"class":128,"line":188},[126,1192,158],{"emptyLinePlaceholder":157},[126,1194,1195],{"class":128,"line":201},[126,1196,158],{"emptyLinePlaceholder":157},[126,1198,1199,1202],{"class":128,"line":214},[126,1200,1201],{"class":428},"@app.callback",[126,1203,1204],{"class":150},"()\n",[126,1206,1207,1209,1212,1215,1217],{"class":128,"line":227},[126,1208,425],{"class":139},[126,1210,1211],{"class":428}," main",[126,1213,1214],{"class":150},"(ctx: typer.Context) -> ",[126,1216,839],{"class":143},[126,1218,559],{"class":150},[126,1220,1221,1224,1226,1229,1232],{"class":128,"line":240},[126,1222,1223],{"class":150},"    theme ",[126,1225,264],{"class":139},[126,1227,1228],{"class":150}," load_theme(",[126,1230,1231],{"class":143},"CONFIG_FILE",[126,1233,470],{"class":150},[126,1235,1236,1239,1241,1243,1246,1249,1252,1255,1257,1259,1261],{"class":128,"line":245},[126,1237,1238],{"class":150},"    ctx.obj ",[126,1240,264],{"class":139},[126,1242,379],{"class":150},[126,1244,1245],{"class":273},"\"out\"",[126,1247,1248],{"class":150},": Out(make_console(theme)), ",[126,1250,1251],{"class":273},"\"err\"",[126,1253,1254],{"class":150},": Out(make_console(theme, ",[126,1256,772],{"class":702},[126,1258,264],{"class":139},[126,1260,708],{"class":143},[126,1262,1263],{"class":150},"))}\n",[126,1265,1266],{"class":128,"line":270},[126,1267,158],{"emptyLinePlaceholder":157},[126,1269,1270],{"class":128,"line":286},[126,1271,158],{"emptyLinePlaceholder":157},[126,1273,1274,1277],{"class":128,"line":299},[126,1275,1276],{"class":428},"@app.command",[126,1278,1204],{"class":150},[126,1280,1281,1283,1286,1289,1291,1293,1295],{"class":128,"line":312},[126,1282,425],{"class":139},[126,1284,1285],{"class":428}," deploy",[126,1287,1288],{"class":150},"(ctx: typer.Context, site: ",[126,1290,254],{"class":143},[126,1292,876],{"class":150},[126,1294,839],{"class":143},[126,1296,559],{"class":150},[126,1298,1299,1302,1304,1307,1309,1312,1314],{"class":128,"line":325},[126,1300,1301],{"class":150},"    out, err ",[126,1303,264],{"class":139},[126,1305,1306],{"class":150}," ctx.obj[",[126,1308,1245],{"class":273},[126,1310,1311],{"class":150},"], ctx.obj[",[126,1313,1251],{"class":273},[126,1315,1316],{"class":150},"]\n",[126,1318,1319,1322,1324,1327,1329,1332,1334,1337],{"class":128,"line":338},[126,1320,1321],{"class":150},"    out.success(",[126,1323,573],{"class":139},[126,1325,1326],{"class":273},"\"deployed ",[126,1328,579],{"class":143},[126,1330,1331],{"class":150},"site",[126,1333,588],{"class":143},[126,1335,1336],{"class":273}," to [path]prod[\u002F]\"",[126,1338,470],{"class":150},[126,1340,1341,1344,1347],{"class":128,"line":351},[126,1342,1343],{"class":150},"    err.warning(",[126,1345,1346],{"class":273},"\"2 files over 1 MB\"",[126,1348,470],{"class":150},[126,1350,1351,1354,1357],{"class":128,"line":364},[126,1352,1353],{"class":150},"    err.detail(",[126,1355,1356],{"class":273},"\"uploaded 14 files in 3.2s\"",[126,1358,470],{"class":150},[1360,1361,1363],"h3",{"id":1362},"the-pieces","The pieces",[10,1365,1366,1370,1371,1374],{},[31,1367,1368],{},[14,1369,248],{}," is the whole visual language in seven lines. ",[14,1372,1373],{},"inherit=True"," keeps Rich's built-in styles (used by tables, tracebacks and syntax highlighting) available alongside yours.",[10,1376,1377,1382,1383,1386,1387,1390,1391,1394,1395,1397],{},[31,1378,1379],{},[14,1380,1381],{},"Out"," is the only way commands produce status messages. It fixes not just colour but ",[108,1384,1385],{},"shape",": every success starts with ",[14,1388,1389],{},"✓",", every error with ",[14,1392,1393],{},"✗",", hints are indented and muted. Consistency of shape is what lets people scan output quickly — they learn once that ",[14,1396,1393],{}," lines matter.",[10,1399,1400,1403,1404,1407,1408,66],{},[31,1401,1402],{},"Symbols and words carry the meaning."," Colour reinforces them. With ",[14,1405,1406],{},"NO_COLOR",", a colour-blind user, or output piped to a file, \"✗ deploy failed\" still says everything; see ",[62,1409,1411],{"href":1410},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Frespecting-no-color-and-force-color\u002F","respecting NO_COLOR and FORCE_COLOR",[10,1413,1414,1419],{},[31,1415,1416],{},[14,1417,1418],{},"highlight=False"," stops Rich's automatic highlighter from colouring numbers and strings inside your messages in ways your theme did not choose.",[10,1421,1422,1425,1426,1429],{},[31,1423,1424],{},"User overrides are validated."," A ",[14,1427,1428],{},"[theme]"," table in the user's config can change any style; unknown names and invalid style strings are rejected with a clear message rather than failing later in the middle of output.",[68,1431,1433],{"id":1432},"a-palette-that-survives-every-terminal-theme","A palette that survives every terminal theme",[90,1435],{"name":1436},"th-palette-matrix",[10,1438,1439],{},"Users run light themes, dark themes, high-contrast themes and custom palettes. Two rules keep text readable on all of them:",[73,1441,1442,1471],{},[76,1443,1444,1447,1448,38,1451,38,1454,38,1457,1460,1461,1463,1464,38,1467,1470],{},[31,1445,1446],{},"Use the named ANSI colours"," — ",[14,1449,1450],{},"red",[14,1452,1453],{},"green",[14,1455,1456],{},"yellow",[14,1458,1459],{},"cyan"," — for semantic styles. Terminal themes remap these sixteen colours to shades that suit their background, so ",[14,1462,1453],{}," is readable on both light and dark. Exact RGB values (",[14,1465,1466],{},"#777777",[14,1468,1469],{},"rgb(0,0,255)",") are rendered literally and disappear on one theme or the other.",[76,1472,1473,1476,1477,1480,1481,1484],{},[31,1474,1475],{},"Add a second cue for important styles."," ",[14,1478,1479],{},"bold red"," for errors is still distinguishable in a theme with a muted red; ",[14,1482,1483],{},"dim"," for secondary text adapts to the theme's foreground instead of choosing a grey.",[10,1486,1487,1488,1491],{},"Test the palette once in a light and a dark theme — and once with ",[14,1489,1490],{},"NO_COLOR=1"," — before settling on it.",[68,1493,1495],{"id":1494},"ux-considerations","UX considerations",[90,1497],{"name":1498},"th-terminal",[73,1500,1501,1507,1521,1539],{},[76,1502,1503,1506],{},[31,1504,1505],{},"Few styles, used strictly."," Seven semantic styles cover almost every CLI. More styles means more meanings users must learn.",[76,1508,1509,1512,1513,1516,1517,66],{},[31,1510,1511],{},"Style only human output."," Machine-readable output (",[14,1514,1515],{},"--json",", CSV) is never styled, whatever the theme; see ",[62,1518,1520],{"href":1519},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Femitting-json-output-for-scripting\u002F","emitting JSON output for scripting",[76,1522,1523,1526,1527,1530,1531,1534,1535,66],{},[31,1524,1525],{},"Consistent across tables too."," Use theme names in table cells (",[14,1528,1529],{},"\"[error]failed[\u002F]\"",") and column ",[14,1532,1533],{},"style="," arguments, so tables and messages agree — as in ",[62,1536,1538],{"href":1537},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Frendering-tables-and-json-with-rich\u002F","rendering tables and JSON with Rich",[76,1540,1541,1544,1545,1547],{},[31,1542,1543],{},"Document the override."," A sentence in the docs showing the ",[14,1546,1428],{}," table lets users with unusual palettes fix readability themselves.",[68,1549,1551],{"id":1550},"testing-the-behaviour","Testing the behaviour",[10,1553,1554,1555,1558],{},"Render into a ",[14,1556,1557],{},"StringIO"," console to test both the plain text (the meaning) and, with a forced terminal and a fixed colour system, that styles really come from the theme:",[117,1560,1562],{"className":119,"code":1561,"language":121,"meta":122,"style":122},"# tests\u002Ftest_theme.py\nimport io\n\nimport pytest\nfrom rich.console import Console\n\nfrom mytool.theme import DEFAULT_STYLES, Out, load_theme, make_console\n\n\ndef render(out_fn, theme=None, **console_kw) -> str:\n    console = make_console(theme or load_theme(), file=io.StringIO(), width=80, **console_kw)\n    out_fn(Out(console))\n    return console.file.getvalue()\n\n\ndef test_plain_output_keeps_meaning_without_colour():\n    text = render(lambda o: o.error(\"deploy failed\", hint=\"run mytool auth login\"), color_system=None)\n    assert text == \"✗ deploy failed\\n  hint: run mytool auth login\\n\"\n\n\ndef test_styles_come_from_the_theme():\n    text = render(lambda o: o.success(\"deployed\"), force_terminal=True, color_system=\"standard\")\n    assert \"\\x1b[32m\" in text                       # green, from the 'success' style\n\n\ndef test_user_override(tmp_path):\n    cfg = tmp_path \u002F \"config.toml\"\n    cfg.write_text('[theme]\\nsuccess = \"bold blue\"\\n')\n    theme = load_theme(cfg)\n    assert str(theme.styles[\"success\"]) == \"bold blue\"\n\n\n@pytest.mark.parametrize(\"toml, message\", [\n    ('[theme]\\nsucess = \"green\"\\n', \"unknown style\"),\n    ('[theme]\\nerror = \"not-a-colour\"\\n', \"invalid style\"),\n])\ndef test_bad_overrides_are_explained(tmp_path, toml, message):\n    cfg = tmp_path \u002F \"config.toml\"\n    cfg.write_text(toml)\n    with pytest.raises(ValueError, match=message):\n        load_theme(cfg)\n\n\ndef test_every_semantic_style_parses():\n    theme = load_theme()\n    for name in DEFAULT_STYLES:\n        assert name in theme.styles\n",[14,1563,1564,1569,1576,1580,1587,1597,1601,1614,1618,1622,1647,1686,1691,1698,1702,1706,1716,1756,1781,1785,1789,1798,1834,1855,1859,1863,1873,1889,1909,1918,1938,1942,1946,1959,1983,2005,2010,2020,2032,2037,2058,2063,2067,2071,2080,2089,2102],{"__ignoreMap":122},[126,1565,1566],{"class":128,"line":129},[126,1567,1568],{"class":132},"# tests\u002Ftest_theme.py\n",[126,1570,1571,1573],{"class":128,"line":136},[126,1572,164],{"class":139},[126,1574,1575],{"class":150}," io\n",[126,1577,1578],{"class":128,"line":154},[126,1579,158],{"emptyLinePlaceholder":157},[126,1581,1582,1584],{"class":128,"line":161},[126,1583,164],{"class":139},[126,1585,1586],{"class":150}," pytest\n",[126,1588,1589,1591,1593,1595],{"class":128,"line":170},[126,1590,140],{"class":139},[126,1592,193],{"class":150},[126,1594,164],{"class":139},[126,1596,198],{"class":150},[126,1598,1599],{"class":128,"line":183},[126,1600,158],{"emptyLinePlaceholder":157},[126,1602,1603,1605,1607,1609,1611],{"class":128,"line":188},[126,1604,140],{"class":139},[126,1606,1154],{"class":150},[126,1608,164],{"class":139},[126,1610,556],{"class":143},[126,1612,1613],{"class":150},", Out, load_theme, make_console\n",[126,1615,1616],{"class":128,"line":201},[126,1617,158],{"emptyLinePlaceholder":157},[126,1619,1620],{"class":128,"line":214},[126,1621,158],{"emptyLinePlaceholder":157},[126,1623,1624,1626,1629,1632,1634,1636,1638,1640,1643,1645],{"class":128,"line":227},[126,1625,425],{"class":139},[126,1627,1628],{"class":428}," render",[126,1630,1631],{"class":150},"(out_fn, theme",[126,1633,264],{"class":139},[126,1635,839],{"class":143},[126,1637,38],{"class":150},[126,1639,750],{"class":139},[126,1641,1642],{"class":150},"console_kw) -> ",[126,1644,254],{"class":143},[126,1646,559],{"class":150},[126,1648,1649,1652,1654,1657,1660,1663,1666,1668,1671,1674,1676,1679,1681,1683],{"class":128,"line":240},[126,1650,1651],{"class":150},"    console ",[126,1653,264],{"class":139},[126,1655,1656],{"class":150}," make_console(theme ",[126,1658,1659],{"class":139},"or",[126,1661,1662],{"class":150}," load_theme(), ",[126,1664,1665],{"class":702},"file",[126,1667,264],{"class":139},[126,1669,1670],{"class":150},"io.StringIO(), ",[126,1672,1673],{"class":702},"width",[126,1675,264],{"class":139},[126,1677,1678],{"class":143},"80",[126,1680,38],{"class":150},[126,1682,750],{"class":139},[126,1684,1685],{"class":150},"console_kw)\n",[126,1687,1688],{"class":128,"line":245},[126,1689,1690],{"class":150},"    out_fn(Out(console))\n",[126,1692,1693,1695],{"class":128,"line":270},[126,1694,696],{"class":139},[126,1696,1697],{"class":150}," console.file.getvalue()\n",[126,1699,1700],{"class":128,"line":286},[126,1701,158],{"emptyLinePlaceholder":157},[126,1703,1704],{"class":128,"line":299},[126,1705,158],{"emptyLinePlaceholder":157},[126,1707,1708,1710,1713],{"class":128,"line":312},[126,1709,425],{"class":139},[126,1711,1712],{"class":428}," test_plain_output_keeps_meaning_without_colour",[126,1714,1715],{"class":150},"():\n",[126,1717,1718,1721,1723,1726,1729,1732,1735,1737,1739,1741,1744,1747,1750,1752,1754],{"class":128,"line":325},[126,1719,1720],{"class":150},"    text ",[126,1722,264],{"class":139},[126,1724,1725],{"class":150}," render(",[126,1727,1728],{"class":139},"lambda",[126,1730,1731],{"class":150}," o: o.error(",[126,1733,1734],{"class":273},"\"deploy failed\"",[126,1736,38],{"class":150},[126,1738,1077],{"class":702},[126,1740,264],{"class":139},[126,1742,1743],{"class":273},"\"run mytool auth login\"",[126,1745,1746],{"class":150},"), ",[126,1748,1749],{"class":702},"color_system",[126,1751,264],{"class":139},[126,1753,839],{"class":143},[126,1755,470],{"class":150},[126,1757,1758,1761,1764,1767,1770,1773,1776,1778],{"class":128,"line":338},[126,1759,1760],{"class":139},"    assert",[126,1762,1763],{"class":150}," text ",[126,1765,1766],{"class":139},"==",[126,1768,1769],{"class":273}," \"✗ deploy failed",[126,1771,1772],{"class":143},"\\n",[126,1774,1775],{"class":273},"  hint: run mytool auth login",[126,1777,1772],{"class":143},[126,1779,1780],{"class":273},"\"\n",[126,1782,1783],{"class":128,"line":351},[126,1784,158],{"emptyLinePlaceholder":157},[126,1786,1787],{"class":128,"line":364},[126,1788,158],{"emptyLinePlaceholder":157},[126,1790,1791,1793,1796],{"class":128,"line":370},[126,1792,425],{"class":139},[126,1794,1795],{"class":428}," test_styles_come_from_the_theme",[126,1797,1715],{"class":150},[126,1799,1800,1802,1804,1806,1808,1811,1814,1816,1819,1821,1823,1825,1827,1829,1832],{"class":128,"line":412},[126,1801,1720],{"class":150},[126,1803,264],{"class":139},[126,1805,1725],{"class":150},[126,1807,1728],{"class":139},[126,1809,1810],{"class":150}," o: o.success(",[126,1812,1813],{"class":273},"\"deployed\"",[126,1815,1746],{"class":150},[126,1817,1818],{"class":702},"force_terminal",[126,1820,264],{"class":139},[126,1822,708],{"class":143},[126,1824,38],{"class":150},[126,1826,1749],{"class":702},[126,1828,264],{"class":139},[126,1830,1831],{"class":273},"\"standard\"",[126,1833,470],{"class":150},[126,1835,1836,1838,1841,1844,1847,1849,1852],{"class":128,"line":417},[126,1837,1760],{"class":139},[126,1839,1840],{"class":273}," \"",[126,1842,1843],{"class":143},"\\x1b",[126,1845,1846],{"class":273},"[32m\"",[126,1848,553],{"class":139},[126,1850,1851],{"class":150}," text                       ",[126,1853,1854],{"class":132},"# green, from the 'success' style\n",[126,1856,1857],{"class":128,"line":422},[126,1858,158],{"emptyLinePlaceholder":157},[126,1860,1861],{"class":128,"line":448},[126,1862,158],{"emptyLinePlaceholder":157},[126,1864,1865,1867,1870],{"class":128,"line":454},[126,1866,425],{"class":139},[126,1868,1869],{"class":428}," test_user_override",[126,1871,1872],{"class":150},"(tmp_path):\n",[126,1874,1875,1878,1880,1883,1886],{"class":128,"line":473},[126,1876,1877],{"class":150},"    cfg ",[126,1879,264],{"class":139},[126,1881,1882],{"class":150}," tmp_path ",[126,1884,1885],{"class":139},"\u002F",[126,1887,1888],{"class":273}," \"config.toml\"\n",[126,1890,1891,1894,1897,1899,1902,1904,1907],{"class":128,"line":488},[126,1892,1893],{"class":150},"    cfg.write_text(",[126,1895,1896],{"class":273},"'[theme]",[126,1898,1772],{"class":143},[126,1900,1901],{"class":273},"success = \"bold blue\"",[126,1903,1772],{"class":143},[126,1905,1906],{"class":273},"'",[126,1908,470],{"class":150},[126,1910,1911,1913,1915],{"class":128,"line":509},[126,1912,1223],{"class":150},[126,1914,264],{"class":139},[126,1916,1917],{"class":150}," load_theme(cfg)\n",[126,1919,1920,1922,1925,1928,1930,1933,1935],{"class":128,"line":526},[126,1921,1760],{"class":139},[126,1923,1924],{"class":143}," str",[126,1926,1927],{"class":150},"(theme.styles[",[126,1929,382],{"class":273},[126,1931,1932],{"class":150},"]) ",[126,1934,1766],{"class":139},[126,1936,1937],{"class":273}," \"bold blue\"\n",[126,1939,1940],{"class":128,"line":541},[126,1941,158],{"emptyLinePlaceholder":157},[126,1943,1944],{"class":128,"line":562},[126,1945,158],{"emptyLinePlaceholder":157},[126,1947,1948,1951,1953,1956],{"class":128,"line":614},[126,1949,1950],{"class":428},"@pytest.mark.parametrize",[126,1952,465],{"class":150},[126,1954,1955],{"class":273},"\"toml, message\"",[126,1957,1958],{"class":150},", [\n",[126,1960,1961,1964,1966,1968,1971,1973,1975,1977,1980],{"class":128,"line":622},[126,1962,1963],{"class":150},"    (",[126,1965,1896],{"class":273},[126,1967,1772],{"class":143},[126,1969,1970],{"class":273},"sucess = \"green\"",[126,1972,1772],{"class":143},[126,1974,1906],{"class":273},[126,1976,38],{"class":150},[126,1978,1979],{"class":273},"\"unknown style\"",[126,1981,1982],{"class":150},"),\n",[126,1984,1985,1987,1989,1991,1994,1996,1998,2000,2003],{"class":128,"line":628},[126,1986,1963],{"class":150},[126,1988,1896],{"class":273},[126,1990,1772],{"class":143},[126,1992,1993],{"class":273},"error = \"not-a-colour\"",[126,1995,1772],{"class":143},[126,1997,1906],{"class":273},[126,1999,38],{"class":150},[126,2001,2002],{"class":273},"\"invalid style\"",[126,2004,1982],{"class":150},[126,2006,2007],{"class":128,"line":642},[126,2008,2009],{"class":150},"])\n",[126,2011,2012,2014,2017],{"class":128,"line":682},[126,2013,425],{"class":139},[126,2015,2016],{"class":428}," test_bad_overrides_are_explained",[126,2018,2019],{"class":150},"(tmp_path, toml, message):\n",[126,2021,2022,2024,2026,2028,2030],{"class":128,"line":693},[126,2023,1877],{"class":150},[126,2025,264],{"class":139},[126,2027,1882],{"class":150},[126,2029,1885],{"class":139},[126,2031,1888],{"class":273},[126,2033,2034],{"class":128,"line":713},[126,2035,2036],{"class":150},"    cfg.write_text(toml)\n",[126,2038,2039,2042,2045,2048,2050,2053,2055],{"class":128,"line":718},[126,2040,2041],{"class":139},"    with",[126,2043,2044],{"class":150}," pytest.raises(",[126,2046,2047],{"class":143},"ValueError",[126,2049,38],{"class":150},[126,2051,2052],{"class":702},"match",[126,2054,264],{"class":139},[126,2056,2057],{"class":150},"message):\n",[126,2059,2060],{"class":128,"line":723},[126,2061,2062],{"class":150},"        load_theme(cfg)\n",[126,2064,2065],{"class":128,"line":756},[126,2066,158],{"emptyLinePlaceholder":157},[126,2068,2069],{"class":128,"line":795},[126,2070,158],{"emptyLinePlaceholder":157},[126,2072,2073,2075,2078],{"class":128,"line":800},[126,2074,425],{"class":139},[126,2076,2077],{"class":428}," test_every_semantic_style_parses",[126,2079,1715],{"class":150},[126,2081,2082,2084,2086],{"class":128,"line":805},[126,2083,1223],{"class":150},[126,2085,264],{"class":139},[126,2087,2088],{"class":150}," load_theme()\n",[126,2090,2091,2094,2096,2098,2100],{"class":128,"line":816},[126,2092,2093],{"class":139},"    for",[126,2095,547],{"class":150},[126,2097,535],{"class":139},[126,2099,556],{"class":143},[126,2101,559],{"class":150},[126,2103,2104,2107,2109,2111],{"class":128,"line":822},[126,2105,2106],{"class":139},"        assert",[126,2108,547],{"class":150},[126,2110,535],{"class":139},[126,2112,2113],{"class":150}," theme.styles\n",[10,2115,2116,2117,2119,2120,2123],{},"The first test is the most valuable: with colour disabled, the exact text is still complete and meaningful. A small lint helps too — a test or pre-commit hook that greps the source for raw colour markup such as ",[14,2118,16],{}," outside ",[14,2121,2122],{},"theme.py"," keeps new code on the semantic names.",[68,2125,2127],{"id":2126},"conclusion","Conclusion",[10,2129,2130,2131,2133],{},"Consistent output comes from naming meanings, not colours. Define a handful of semantic styles in a Rich ",[14,2132,52],{},", route messages through a small helper that fixes their shape and symbols, choose named ANSI colours with a second cue for the important ones, keep machine output unstyled, and let users override styles from their config with validation. Every command then speaks the same visual language, on every terminal theme.",[68,2135,2137],{"id":2136},"frequently-asked-questions","Frequently asked questions",[1360,2139,2141],{"id":2140},"can-typers-own-help-and-error-panels-use-my-theme","Can Typer's own help and error panels use my theme?",[10,2143,2144,2145,2148],{},"Typer's help formatting uses its own Rich styles, configurable through module-level settings in ",[14,2146,2147],{},"typer.rich_utils",". Matching them to your theme is possible but rarely worth it; users expect help to look like help.",[1360,2150,2152],{"id":2151},"should-i-support-light-and-dark-theme-variants","Should I support light and dark theme variants?",[10,2154,2155],{},"Usually not needed if you stick to named ANSI colours, which the terminal adapts for you. If you use RGB colours for branding, provide two themes and let users choose with a config setting or an environment variable.",[1360,2157,2159],{"id":2158},"how-do-i-style-log-output-consistently","How do I style log output consistently?",[10,2161,2162,2163,2166,2167,2170,2171,66],{},"Rich's ",[14,2164,2165],{},"RichHandler"," renders log levels with styles named ",[14,2168,2169],{},"logging.level.warning"," and so on; add those names to your theme to align log colours with message colours. The handler itself is covered in ",[62,2172,2174],{"href":2173},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002F","structured logging for CLI apps",[1360,2176,2178],{"id":2177},"where-should-the-theme-live-in-the-codebase","Where should the theme live in the codebase?",[10,2180,2181,2182,2184,2185,2187],{},"In one small module next to the command layer, as ",[14,2183,2122],{}," above, imported only by code that produces human output. Core logic should never import it — core returns data and raises errors, and the command layer decides how they look. That separation is what lets the same core serve a ",[14,2186,1515],{}," mode, a TUI and tests without any styling concerns.",[1360,2189,2191],{"id":2190},"are-emoji-a-good-fit-for-status-symbols","Are emoji a good fit for status symbols?",[10,2193,2194,2195,2198],{},"Plain symbols (",[14,2196,2197],{},"✓ ✗ !",") render at a predictable width in nearly every font; emoji vary in width and may show as boxes on servers and older consoles. Use symbols, and provide ASCII fallbacks when the output encoding cannot represent them.",[68,2200,2202],{"id":2201},"related","Related",[73,2204,2205,2211,2217,2223,2228],{},[76,2206,2207,2208],{},"Up: ",[62,2209,2210],{"href":64},"Interactive terminal UI with Rich",[76,2212,2213],{},[62,2214,2216],{"href":2215},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Flive-dashboards-with-rich-live\u002F","Live dashboards with Rich Live",[76,2218,2219],{},[62,2220,2222],{"href":2221},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Fbuilding-interactive-prompts-and-menus\u002F","Building interactive prompts and menus",[76,2224,2225],{},[62,2226,2227],{"href":1410},"Respecting NO_COLOR and FORCE_COLOR",[76,2229,2230],{},[62,2231,2233],{"href":2232},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Ffriendly-error-messages-and-tracebacks\u002F","Friendly error messages and tracebacks",[2235,2236,2237],"style",{},"html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":122,"searchDepth":136,"depth":136,"links":2239},[2240,2241,2242,2245,2246,2247,2248,2249,2256],{"id":70,"depth":136,"text":71},{"id":87,"depth":136,"text":88},{"id":114,"depth":136,"text":115,"children":2243},[2244],{"id":1362,"depth":154,"text":1363},{"id":1432,"depth":136,"text":1433},{"id":1494,"depth":136,"text":1495},{"id":1550,"depth":136,"text":1551},{"id":2126,"depth":136,"text":2127},{"id":2136,"depth":136,"text":2137,"children":2250},[2251,2252,2253,2254,2255],{"id":2140,"depth":154,"text":2141},{"id":2151,"depth":154,"text":2152},{"id":2158,"depth":154,"text":2159},{"id":2177,"depth":154,"text":2178},{"id":2190,"depth":154,"text":2191},{"id":2201,"depth":136,"text":2202},"2026-09-18","Give a Python CLI one visual language: semantic Rich theme styles, a small output helper, palettes that work on light and dark terminals, user overrides and tests.","beginner",false,"md",{},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Ftheming-rich-output-consistently",{"title":5,"description":2258},"advanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Ftheming-rich-output-consistently\u002Findex",[2267,2268,2269,2270],"rich","theming","terminal-ux","colour","nSER9e83IGeRxtMN50Gmt8bEg6JmAjL8HJvlSZIT6AE",[2273,2276,2279,2282,2285,2288,2291,2294,2297,2300,2303,2306,2309,2312,2315,2318,2321,2324,2327,2330,2333,2336,2339,2342,2345,2348,2351,2354,2357,2360,2363,2366,2369,2372,2375,2378,2381,2384,2387,2388,2391,2394,2397,2400,2403,2406,2409,2412,2415,2418,2421,2424,2427,2430,2433,2436,2439,2442,2445,2448,2451,2454,2457,2460,2463,2466,2469,2472,2475,2478,2481,2484,2487,2490,2493,2496,2499,2502,2505,2508,2511,2514,2517,2520,2523,2526,2529,2532,2535,2538,2541,2544,2546,2549,2552,2555,2558,2561,2564,2567,2570,2573,2576,2579,2582,2585,2588,2591,2594,2597,2600,2603,2606,2609,2612,2615,2618,2621,2624,2627,2630,2633,2636,2639,2642,2645,2648,2651,2654,2657,2660,2663,2666,2669,2672,2675,2678,2681,2684,2687,2690,2693,2696,2699,2702,2705,2708,2711,2714,2717,2720,2723,2726,2729,2732,2735,2738,2741,2744,2747,2750,2753,2756,2759,2762,2765,2768,2771,2774,2777,2780,2783,2786,2789,2792,2795,2798,2801,2804,2807,2810,2813,2816],{"path":2274,"title":2275},"\u002Fabout","About Python CLI Toolcraft",{"path":2277,"title":2278},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies","Advanced Argument Validation Strategies",{"path":2280,"title":2281},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fparsing-nested-json-arguments-in-python-clis","Parsing Nested JSON Args in Python CLIs",{"path":2283,"title":2284},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-dependent-and-conflicting-options","Validating Dependent and Conflicting CLI Options",{"path":2286,"title":2287},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-file-and-directory-paths-in-clis","Validating File and Directory Paths in CLIs",{"path":2289,"title":2290},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fwriting-custom-click-parameter-types","Writing Custom Click Parameter Types",{"path":2292,"title":2293},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual\u002Fbuilding-your-first-textual-app","Building Your First Textual App for a Python CLI",{"path":2295,"title":2296},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual\u002Fchoosing-between-a-cli-a-prompt-flow-and-a-tui","Choosing Between a CLI, a Prompt Flow and a TUI",{"path":2298,"title":2299},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual","Building Terminal UIs with Textual for Python CLIs",{"path":2301,"title":2302},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual\u002Ftesting-textual-apps-with-pilot","Testing Textual Apps with Pilot",{"path":2304,"title":2305},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fadding-examples-and-epilogs-to-help-output","Adding Examples and Epilogs to Help Output",{"path":2307,"title":2308},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fgenerating-man-pages-and-docs-from-a-cli","Generating Man Pages and Docs from a CLI",{"path":2310,"title":2311},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation","CLI Help Output and Documentation",{"path":2313,"title":2314},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fversioning-and-deprecating-cli-flags","Versioning and Deprecating CLI Flags",{"path":2316,"title":2317},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fwriting-help-text-users-actually-read","Writing Help Text Users Actually Read",{"path":2319,"title":2320},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fadapting-output-to-terminal-width","Adapting Python CLI Output to Terminal Width",{"path":2322,"title":2323},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fdetecting-ci-environments-and-non-interactive-shells","Detecting CI Environments and Non-Interactive Shells",{"path":2325,"title":2326},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Ffixing-unicode-and-encoding-errors-on-windows","Fixing Unicode and Encoding Errors on Windows in Python CLIs",{"path":2328,"title":2329},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility","Cross-Platform Terminal Compatibility for Python CLIs",{"path":2331,"title":2332},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Frespecting-no-color-and-force-color","Respecting NO_COLOR and FORCE_COLOR in Python CLIs",{"path":2334,"title":2335},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fchoosing-exit-codes-for-cli-tools","Choosing Exit Codes for CLI Tools",{"path":2337,"title":2338},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fdesigning-an-exception-hierarchy-for-a-cli","Designing an Exception Hierarchy for a Python CLI",{"path":2340,"title":2341},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Ffriendly-error-messages-and-tracebacks","Friendly Error Messages and Tracebacks",{"path":2343,"title":2344},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fhandling-keyboard-interrupt-cleanly","Handling Keyboard Interrupt Cleanly",{"path":2346,"title":2347},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes","Error Handling and Exit Codes for CLIs",{"path":2349,"title":2350},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Freporting-machine-readable-errors-in-json-mode","Reporting Machine-Readable Errors in JSON Mode",{"path":2352,"title":2353},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Fconfig-precedence-flags-env-files-defaults","Config Precedence: Flags, Env, Files, Defaults",{"path":2355,"title":2356},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Fdiscovering-project-config-files-by-walking-up-directories","Discovering Project Config Files by Walking Up Directories",{"path":2358,"title":2359},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars","Handling Config Files and Env Vars in CLIs",{"path":2361,"title":2362},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Floading-yaml-configs-safely-in-cli-apps","Loading YAML configs safely in CLI apps",{"path":2364,"title":2365},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Freading-toml-config-with-tomllib","Reading TOML Config with tomllib in Python CLIs",{"path":2367,"title":2368},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Ftyped-settings-with-pydantic-settings","Typed Settings with pydantic-settings in Python CLIs",{"path":2370,"title":2371},"\u002Fadvanced-input-parsing-user-experience","Advanced Input Parsing for Python CLIs",{"path":2373,"title":2374},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Fadding-progress-bars-and-spinners-to-python-clis","Progress Bars and Spinners for Python CLIs",{"path":2376,"title":2377},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Fbuilding-interactive-prompts-and-menus","Building Interactive Prompts and Menus in Python CLIs",{"path":2379,"title":2380},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich","Interactive Terminal UI with Rich",{"path":2382,"title":2383},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Flive-dashboards-with-rich-live","Live Dashboards with Rich Live in Python CLIs",{"path":2385,"title":2386},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Frendering-tables-and-json-with-rich","Rendering Tables and JSON with Rich",{"path":2263,"title":5},{"path":2389,"title":2390},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis\u002Fdynamic-completion-values-from-apis-and-files","Dynamic Completion Values from APIs and Files",{"path":2392,"title":2393},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis\u002Fenabling-tab-completion-in-click-and-typer","Enabling Tab Completion in Click and Typer",{"path":2395,"title":2396},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis","Shell Completion for Python CLIs",{"path":2398,"title":2399},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis\u002Finstalling-shell-completion-for-bash-zsh-fish","Installing Shell Completion for bash, zsh, fish",{"path":2401,"title":2402},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis\u002Ftesting-shell-completion-in-python-clis","Testing Shell Completion in Python CLIs",{"path":2404,"title":2405},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Fadding-trace-ids-and-context-to-cli-logs","Adding Trace IDs and Context to Python CLI Logs",{"path":2407,"title":2408},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Fadding-verbose-and-quiet-logging-flags","Adding Verbose and Quiet Logging Flags",{"path":2410,"title":2411},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps","Structured Logging for CLI Apps",{"path":2413,"title":2414},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Fstructured-json-logging-in-python-clis","Structured JSON Logging in Python CLIs",{"path":2416,"title":2417},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Fwriting-rotating-log-files-from-a-cli","Writing Rotating Log Files from a Python CLI",{"path":2419,"title":2420},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fdetecting-tty-and-adapting-output","Detecting a TTY and Adapting Output",{"path":2422,"title":2423},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Femitting-json-output-for-scripting","Emitting JSON Output for Scripting",{"path":2425,"title":2426},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fhandling-broken-pipe-and-sigpipe","Handling Broken Pipe and SIGPIPE",{"path":2428,"title":2429},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes","Working with stdin, stdout and Pipes",{"path":2431,"title":2432},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fprocessing-large-files-and-ndjson-streams","Processing Large Files and NDJSON Streams in Python CLIs",{"path":2434,"title":2435},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Freading-piped-input-in-python-clis","Reading Piped Input in Python CLIs",{"path":2437,"title":2438},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fbuilding-an-api-client-cli-with-httpx","Building an API Client CLI with httpx",{"path":2440,"title":2441},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fdownloading-files-with-progress-in-python","Downloading Files with Progress in Python CLIs",{"path":2443,"title":2444},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis","Calling HTTP APIs from Python CLIs",{"path":2446,"title":2447},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Foauth-device-flow-login-for-clis","OAuth Device Flow Login for Python CLIs",{"path":2449,"title":2450},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fpaginating-api-results-in-a-cli","Paginating API Results in a Python CLI",{"path":2452,"title":2453},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fretries-and-backoff-for-cli-http-calls","Retries and Backoff for CLI HTTP Calls",{"path":2455,"title":2456},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Fcancelling-async-tasks-on-ctrl-c","Cancelling Async Tasks on Ctrl+C in Python CLIs",{"path":2458,"title":2459},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis","Concurrency and Async in Python CLIs",{"path":2461,"title":2462},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Fmultiprocessing-for-cpu-bound-cli-tasks","Multiprocessing for CPU-Bound CLI Tasks",{"path":2464,"title":2465},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Fparallelising-cli-work-with-thread-pools","Parallelising CLI Work with Thread Pools",{"path":2467,"title":2468},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Frate-limiting-concurrent-requests-in-clis","Rate-Limiting Concurrent Requests in Python CLIs",{"path":2470,"title":2471},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Frunning-async-code-in-typer-and-click","Running Async Code in Typer and Click",{"path":2473,"title":2474},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fcross-platform-paths-with-pathlib","Cross-Platform Paths with pathlib in CLIs",{"path":2476,"title":2477},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Ffile-locking-for-concurrent-cli-runs","File Locking for Concurrent CLI Runs in Python",{"path":2479,"title":2480},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes","Filesystem Paths and Atomic Writes for CLIs",{"path":2482,"title":2483},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fsafe-temporary-files-and-directories","Safe Temporary Files and Directories in CLIs",{"path":2485,"title":2486},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fstoring-app-data-with-platformdirs","Storing CLI App Data with platformdirs",{"path":2488,"title":2489},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fwriting-files-atomically-in-python-clis","Writing Files Atomically in Python CLIs",{"path":2491,"title":2492},"\u002Fcli-runtime-systems-integration","CLI Runtime & Systems Integration for Python",{"path":2494,"title":2495},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Fbuilding-a-watch-mode-with-watchfiles","Building a Watch Mode with watchfiles in Python",{"path":2497,"title":2498},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Fhandling-sigterm-and-graceful-shutdown","Handling SIGTERM and Graceful Shutdown in CLIs",{"path":2500,"title":2501},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Fhealth-checks-and-heartbeats-for-long-running-clis","Health Checks and Heartbeats for Long-Running CLIs",{"path":2503,"title":2504},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis","Long-Running and Watch-Mode Python CLIs",{"path":2506,"title":2507},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Frunning-a-cli-on-a-schedule-with-cron-and-systemd","Running a Python CLI on a Schedule with cron and systemd",{"path":2509,"title":2510},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Favoiding-shell-injection-in-python-clis","Avoiding Shell Injection in Python CLIs",{"path":2512,"title":2513},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fcalling-external-commands-safely-with-subprocess","Calling External Commands Safely with subprocess",{"path":2515,"title":2516},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fhandling-subprocess-timeouts-and-exit-codes","Handling Subprocess Timeouts and Exit Codes",{"path":2518,"title":2519},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis","Running Subprocesses from Python CLIs",{"path":2521,"title":2522},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fstreaming-subprocess-output-in-real-time","Streaming Subprocess Output in Real Time",{"path":2524,"title":2525},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fwrapping-git-and-other-tools-from-a-python-cli","Wrapping git and Other Tools from a Python CLI",{"path":2527,"title":2528},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis","Secrets and Credentials in Python CLIs",{"path":2530,"title":2531},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fprompting-for-passwords-securely","Prompting for Passwords Securely in Python CLIs",{"path":2533,"title":2534},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Freading-secrets-from-env-and-files","Reading Secrets from Env Vars and Files in CLIs",{"path":2536,"title":2537},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fredacting-secrets-from-cli-output-and-logs","Redacting Secrets from CLI Output and Logs",{"path":2539,"title":2540},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fstoring-tokens-with-keyring","Storing CLI Tokens Securely with keyring",{"path":2542,"title":2543},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fsupporting-multiple-profiles-and-accounts","Supporting Multiple Profiles and Accounts in CLIs",{"path":1885,"title":2545},"Python CLI Toolcraft",{"path":2547,"title":2548},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Fcaching-expensive-work-between-cli-runs","Caching Expensive Work Between Python CLI Runs",{"path":2550,"title":2551},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading","CLI Startup Performance and Lazy Loading",{"path":2553,"title":2554},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Flazy-loading-subcommands-for-faster-startup","Lazy Loading Subcommands for Faster Startup",{"path":2556,"title":2557},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Fprofiling-python-cli-startup-time","Profiling Python CLI Startup Time",{"path":2559,"title":2560},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Freducing-cli-dependency-weight","Reducing CLI Dependency Weight",{"path":2562,"title":2563},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fargparse-subparsers-for-subcommands","argparse Subparsers for Subcommands",{"path":2565,"title":2566},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fargparse-vs-click-vs-typer-comparison","argparse vs Click vs Typer Compared",{"path":2568,"title":2569},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse","Command-Line Parsing with argparse",{"path":2571,"title":2572},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fmigrating-from-argparse-to-typer","Migrating from argparse to Typer",{"path":2574,"title":2575},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fmutually-exclusive-options-in-argparse","Mutually Exclusive Options in argparse",{"path":2577,"title":2578},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fwriting-custom-argparse-actions","Writing Custom argparse Actions in Python",{"path":2580,"title":2581},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions\u002Fadding-dry-run-and-confirmation-to-destructive-commands","Adding Dry-Run and Confirmation to Destructive Commands",{"path":2583,"title":2584},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions\u002Ffollowing-posix-and-gnu-argument-conventions","Following POSIX and GNU Argument Conventions in Python",{"path":2586,"title":2587},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions\u002Fglobal-options-vs-per-command-options","Global Options vs Per-Command Options in Python CLIs",{"path":2589,"title":2590},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions","Designing CLI Interfaces and Conventions in Python",{"path":2592,"title":2593},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions\u002Fnaming-commands-and-flags-consistently","Naming Commands and Flags Consistently in Python CLIs",{"path":2595,"title":2596},"\u002Fmodern-python-cli-frameworks-architecture","Python CLI Frameworks and Architecture",{"path":2598,"title":2599},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fdiscovering-plugins-with-entry-points","Discovering Plugins with Entry Points in Python CLIs",{"path":2601,"title":2602},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fhook-based-plugins-with-pluggy","Hook-Based Plugins for Python CLIs with pluggy",{"path":2604,"title":2605},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis","Plugin Architectures for Extensible CLIs",{"path":2607,"title":2608},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fversioning-a-plugin-api","Versioning a Plugin API for a Python CLI",{"path":2610,"title":2611},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fwriting-a-plugin-for-an-existing-cli","Writing a Plugin for an Existing CLI",{"path":2613,"title":2614},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fbest-practices-for-python-cli-entry-points","Best practices for Python CLI entry points",{"path":2616,"title":2617},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fdependency-injection-patterns-for-cli-commands","Dependency Injection Patterns for CLI Commands",{"path":2619,"title":2620},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fhow-to-structure-a-large-python-cli-project","Structuring a Large Python CLI Project",{"path":2622,"title":2623},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis","Structuring Multi-Command Python CLIs",{"path":2625,"title":2626},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fsharing-common-options-across-commands","Sharing Common Options Across Python CLI Commands",{"path":2628,"title":2629},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fsharing-state-with-click-context-objects","Sharing State with Click Context Objects",{"path":2631,"title":2632},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fend-to-end-testing-an-installed-cli","End-to-End Testing an Installed Python CLI",{"path":2634,"title":2635},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications","Testing Python CLI Applications",{"path":2637,"title":2638},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fmeasuring-cli-test-coverage","Measuring CLI Test Coverage",{"path":2640,"title":2641},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fmocking-filesystem-and-network-in-cli-tests","Mocking the Filesystem and Network in CLI Tests",{"path":2643,"title":2644},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fproperty-based-testing-cli-arguments-with-hypothesis","Property-Based Testing CLI Arguments with Hypothesis",{"path":2646,"title":2647},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fsnapshot-testing-cli-output","Snapshot Testing CLI Output",{"path":2649,"title":2650},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Ftesting-click-commands-with-clirunner","Testing Click Commands with CliRunner",{"path":2652,"title":2653},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Ftesting-interactive-prompts-and-stdin","Testing Interactive Prompts and stdin",{"path":2655,"title":2656},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fbuilding-a-cli-with-subcommands-in-click","Building a CLI with subcommands in Click",{"path":2658,"title":2659},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fbuilding-dynamic-commands-in-click","Building Dynamic Commands in Click",{"path":2661,"title":2662},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fconverting-a-click-app-to-typer","Converting a Click App to Typer",{"path":2664,"title":2665},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each","Typer vs Click: When to Use Each",{"path":2667,"title":2668},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Ftyper-callback-functions-explained","Typer callback functions explained",{"path":2670,"title":2671},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fusing-annotated-options-in-typer","Using Annotated Options in Typer",{"path":2673,"title":2674},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Fautomating-releases-from-git-tags","Automating Python CLI Releases from Git Tags",{"path":2676,"title":2677},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Fcaching-uv-dependencies-in-ci","Caching uv Dependencies in CI for Python CLIs",{"path":2679,"title":2680},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis","CI\u002FCD Pipelines for Python CLIs",{"path":2682,"title":2683},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Fpublishing-to-pypi-with-trusted-publishing","Publishing a CLI to PyPI with Trusted Publishing",{"path":2685,"title":2686},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Fsmoke-testing-the-built-wheel-in-ci","Smoke-Testing the Built Wheel of a Python CLI in CI",{"path":2688,"title":2689},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Ftesting-a-cli-across-python-versions-with-github-actions","Testing a CLI Across Python Versions in GitHub Actions",{"path":2691,"title":2692},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fbuilding-a-cookiecutter-template-for-typer-clis","Building a Cookiecutter Template for Typer CLIs",{"path":2694,"title":2695},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fcopier-vs-cookiecutter-for-cli-templates","Copier vs Cookiecutter for CLI Templates",{"path":2697,"title":2698},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter","CLI Project Scaffolding with Cookiecutter",{"path":2700,"title":2701},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fpost-generation-hooks-in-cli-templates","Post-Generation Hooks in Python CLI Templates",{"path":2703,"title":2704},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fbuilding-cross-platform-release-binaries-in-ci","Building Cross-Platform Release Binaries in CI",{"path":2706,"title":2707},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fbundling-a-python-cli-with-pyinstaller","Bundling a Python CLI with PyInstaller",{"path":2709,"title":2710},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fhomebrew-and-scoop-packaging-for-python-clis","Homebrew and Scoop Packaging for Python CLIs",{"path":2712,"title":2713},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries","Distributing CLIs as Standalone Binaries",{"path":2715,"title":2716},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fnuitka-vs-pyinstaller-for-python-clis","Nuitka vs PyInstaller for Python CLI Binaries",{"path":2718,"title":2719},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fshipping-a-cli-as-a-zipapp-with-shiv","Shipping a CLI as a Zipapp with shiv",{"path":2721,"title":2722},"\u002Fproject-setup-dependency-management","Project Setup & Dependency Management",{"path":2724,"title":2725},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code\u002Fconfiguring-ruff-for-a-cli-project","Configuring Ruff for a Python CLI Project",{"path":2727,"title":2728},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code\u002Fenforcing-import-boundaries-in-a-cli-codebase","Enforcing Import Boundaries in a Python CLI Codebase",{"path":2730,"title":2731},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code","Linting and Type-Checking Python CLI Code",{"path":2733,"title":2734},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code\u002Ftype-checking-click-and-typer-code-with-mypy","Type-Checking Click and Typer Code with mypy",{"path":2736,"title":2737},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fautomating-changelogs-with-conventional-commits","Automating Changelogs with Conventional Commits",{"path":2739,"title":2740},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fderiving-versions-from-git-tags-with-hatch-vcs","Deriving CLI Versions from Git Tags with hatch-vcs",{"path":2742,"title":2743},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fexposing-version-info-and-build-metadata","Exposing Version Info and Build Metadata",{"path":2745,"title":2746},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs","Managing CLI Versioning & Changelogs",{"path":2748,"title":2749},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fsemantic-versioning-policy-for-cli-tools","A Semantic Versioning Policy for CLI Tools",{"path":2751,"title":2752},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fbuilding-wheels-and-sdists-for-python-clis","Building Wheels and sdists for Python CLIs",{"path":2754,"title":2755},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fbundling-data-files-with-importlib-resources","Bundling Data Files with importlib.resources in CLIs",{"path":2757,"title":2758},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution","Packaging Python CLIs for Distribution",{"path":2760,"title":2761},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Finstalling-and-distributing-clis-with-pipx","Installing and Distributing CLIs with pipx",{"path":2763,"title":2764},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fpublishing-a-python-cli-to-pypi","Publishing a Python CLI to PyPI",{"path":2766,"title":2767},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fwriting-pyproject-toml-metadata-for-a-cli","Writing pyproject.toml Metadata for a Python CLI",{"path":2769,"title":2770},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development","Poetry Workflows for CLI Development",{"path":2772,"title":2773},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fmigrating-a-cli-from-poetry-to-uv","Migrating a Python CLI from Poetry to uv",{"path":2775,"title":2776},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fpoetry-dependency-groups-for-cli-tooling","Poetry Dependency Groups for CLI Tooling",{"path":2778,"title":2779},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fpoetry-entry-points-and-scripts-for-clis","Poetry Entry Points and Scripts for CLIs",{"path":2781,"title":2782},"\u002Fproject-setup-dependency-management\u002Fpre-commit-hooks-for-cli-projects","Pre-commit Hooks for CLI Projects",{"path":2784,"title":2785},"\u002Fproject-setup-dependency-management\u002Fpre-commit-hooks-for-cli-projects\u002Fsetting-up-pre-commit-for-python-cli-repos","Setting up pre-commit for Python CLI repos",{"path":2787,"title":2788},"\u002Fproject-setup-dependency-management\u002Fpre-commit-hooks-for-cli-projects\u002Fshipping-your-cli-as-a-pre-commit-hook","Shipping Your Python CLI as a pre-commit Hook",{"path":2790,"title":2791},"\u002Fproject-setup-dependency-management\u002Fpre-commit-hooks-for-cli-projects\u002Fwriting-local-pre-commit-hooks-in-python","Writing Local pre-commit Hooks in Python",{"path":2793,"title":2794},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management","uv for Python CLI Dependency Management",{"path":2796,"title":2797},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management\u002Frunning-one-off-cli-scripts-with-uv-run","Running One-Off CLI Scripts with uv run and PEP 723",{"path":2799,"title":2800},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management\u002Fuv-init-vs-poetry-init-for-cli-tools","uv init vs poetry init for CLI tools",{"path":2802,"title":2803},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management\u002Fuv-tool-install-vs-pipx-for-clis","uv tool install vs pipx for CLIs",{"path":2805,"title":2806},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management\u002Fuv-workspaces-for-multi-package-clis","uv Workspaces for Multi-Package Python CLIs",{"path":2808,"title":2809},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices","Python CLI Env Isolation Best Practices",{"path":2811,"title":2812},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fmanaging-virtual-environments-for-cross-platform-clis","Managing Python CLI Virtual Environments",{"path":2814,"title":2815},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fpinning-the-python-version-for-a-cli","Pinning the Python Version for a CLI",{"path":2817,"title":2818},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fsupporting-multiple-python-versions-with-nox","Supporting Multiple Python Versions with nox",1789736905046]