[{"data":1,"prerenderedAt":2868},["ShallowReactive",2],{"page-\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fadapting-output-to-terminal-width\u002F":3,"content-directory":2320},{"id":4,"title":5,"body":6,"date":2305,"description":2306,"difficulty":2307,"draft":2308,"extension":2309,"meta":2310,"navigation":171,"path":2311,"seo":2312,"stem":2313,"tags":2314,"updated":2305,"__hash__":2319},"content\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fadapting-output-to-terminal-width\u002Findex.md","Adapting Python CLI Output to Terminal Width",{"type":7,"value":8,"toc":2289},"minimark",[9,28,33,43,47,51,75,79,82,103,106,126,130,1530,1533,1595,1598,1602,1649,1653,1670,2167,2173,2177,2194,2198,2203,2212,2216,2223,2227,2238,2242,2249,2253,2285],[10,11,12,13,17,18,21,22,27],"p",{},"Your listing command looks great in a maximised terminal on a large monitor. Then someone runs it in an 80-column SSH session, a split tmux pane or the narrow terminal panel of an IDE, and every row wraps across three lines, columns misalign, and the one field they needed — the status — is pushed off the right edge. The opposite also happens: output designed for 80 columns wastes a wide terminal by truncating messages that would have fitted. A CLI's human-readable output should adapt to the width it actually has. This guide shows how to find that width reliably, decide which columns matter most, truncate gracefully with an ellipsis, give users ",[14,15,16],"code",{},"--wide"," and ",[14,19,20],{},"--width"," controls, and make sure machine-readable output is never affected. It belongs to the ",[23,24,26],"a",{"href":25},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002F","cross-platform terminal compatibility topic",".",[29,30,32],"h2",{"id":31},"prerequisites","Prerequisites",[34,35,36,40],"ul",{},[37,38,39],"li",{},"Python 3.10+, Typer and Rich.",[37,41,42],{},"A command with tabular or wrapped output — the example lists CI builds, with a mix of short essential columns and long optional ones.",[29,44,46],{"id":45},"finding-the-width","Finding the width",[48,49],"inline-diagram",{"name":50},"tw-sources",[10,52,53,56,57,60,61,63,64,67,68,71,72,74],{},[14,54,55],{},"shutil.get_terminal_size()"," does the standard lookup: it returns the ",[14,58,59],{},"COLUMNS"," environment variable if set, otherwise asks the terminal attached to stdout, otherwise returns the fallback you pass. That order matters. ",[14,62,59],{}," lets users — and tests — override the width without a real terminal, and the fallback of 80 is what pipes, files and CI logs get. Rich's ",[14,65,66],{},"Console"," performs the same lookup for its own ",[14,69,70],{},"width",". Add an explicit ",[14,73,20],{}," option at the top of the chain for reproducible output in documentation and screenshots.",[29,76,78],{"id":77},"deciding-what-to-show","Deciding what to show",[10,80,81],{},"Not every column is equally important. Before writing layout code, rank them:",[34,83,84,91,97],{},[37,85,86,90],{},[87,88,89],"strong",{},"Essential"," columns identify the row and its state — ID, name, status. They are never truncated or dropped.",[37,92,93,96],{},[87,94,95],{},"Useful"," columns add context — branch, start time. They may be truncated and are dropped on narrow terminals.",[37,98,99,102],{},[87,100,101],{},"Nice-to-have"," columns — long descriptions, commit messages — absorb whatever width remains and are the first to go.",[48,104],{"name":105},"tw-strategies",[10,107,108,109,112,113,116,117,120,121,125],{},"With priorities decided, four strategies cover every width: ",[87,110,111],{},"drop"," low-priority columns below a threshold, ",[87,114,115],{},"truncate"," long values with an ellipsis (showing that something is missing, not silently cutting it), ",[87,118,119],{},"let one flexible column absorb"," the leftover space, and offer ",[87,122,123],{},[14,124,16],{}," to show everything in full when the user wants it.",[29,127,129],{"id":128},"the-recipe","The recipe",[131,132,137],"pre",{"className":133,"code":134,"language":135,"meta":136,"style":136},"language-python shiki shiki-themes github-light github-dark","# src\u002Fmytool\u002Fcli.py\nfrom __future__ import annotations\n\nimport json\nimport shutil\nfrom dataclasses import asdict, dataclass\nfrom typing import Annotated\n\nimport typer\nfrom rich.console import Console\nfrom rich.table import Table\n\napp = typer.Typer()\n\n\n@dataclass\nclass Build:\n    id: str\n    project: str\n    status: str\n    branch: str\n    started: str\n    commit_message: str\n\n\nBUILDS = [\n    Build(\"4411\", \"web\", \"passed\", \"feature\u002Fnew-navigation-menu\", \"2m ago\",\n          \"Rework the navigation menu so keyboard users can reach every section\"),\n    Build(\"4410\", \"billing\", \"failed\", \"main\", \"9m ago\", \"Bump httpx\"),\n]\n\n# (header, attribute, minimum terminal width at which the column is shown)\nCOLUMNS = [\n    (\"ID\", \"id\", 0),\n    (\"PROJECT\", \"project\", 0),\n    (\"STATUS\", \"status\", 0),\n    (\"BRANCH\", \"branch\", 50),\n    (\"STARTED\", \"started\", 70),\n    (\"MESSAGE\", \"commit_message\", 100),\n]\n\n\ndef terminal_width(explicit: int | None) -> int:\n    if explicit:\n        return explicit\n    return shutil.get_terminal_size(fallback=(80, 24)).columns\n\n\ndef build_table(rows: list[Build], width: int, wide: bool) -> Table:\n    table = Table(box=None, pad_edge=False, header_style=\"bold\")\n    shown = [c for c in COLUMNS if wide or width >= c[2]]\n\n    def natural(attr: str, header: str) -> int:\n        longest = max([len(header)] + [len(str(getattr(r, attr))) for r in rows])\n        return longest if wide or attr in (\"id\", \"project\", \"status\") else min(longest, 24)\n\n    fixed = sum(natural(a, h) for h, a, _ in shown if a != \"commit_message\")\n    gutters = 2 * (len(shown) - 1)\n    for header, attr, _ in shown:\n        if attr == \"commit_message\":                   # the flexible column gets what is left\n            room = None if wide else max(20, width - fixed - gutters)\n            table.add_column(header, overflow=\"ellipsis\", no_wrap=not wide, max_width=room)\n        else:\n            table.add_column(header, overflow=\"ellipsis\", no_wrap=True,\n                             min_width=natural(attr, header), max_width=natural(attr, header))\n    for r in rows:\n        table.add_row(*(str(getattr(r, attr)) for _, attr, _ in shown))\n    return table\n\n\n@app.callback()\ndef main() -> None:\n    \"\"\"Build history.\"\"\"\n\n\n@app.command()\ndef builds(\n    width: Annotated[int | None, typer.Option(\"--width\", min=40, help=\"Layout width (default: terminal).\")] = None,\n    wide: Annotated[bool, typer.Option(\"--wide\", \"-w\", help=\"Show every column in full.\")] = False,\n    as_json: Annotated[bool, typer.Option(\"--json\", help=\"Machine-readable output, never truncated.\")] = False,\n) -> None:\n    \"\"\"List recent builds, fitted to the terminal.\"\"\"\n    if as_json:\n        typer.echo(json.dumps([asdict(b) for b in BUILDS]))\n        return\n    cols = terminal_width(width)\n    console = Console(width=10_000 if wide else cols, highlight=False)\n    console.print(build_table(BUILDS, cols, wide))\n\n\nif __name__ == \"__main__\":\n    app()\n","python","",[14,138,139,148,166,173,182,190,203,216,221,229,242,255,260,272,277,282,289,301,313,321,329,337,345,353,358,363,375,409,418,453,459,464,470,479,500,519,538,558,578,598,603,608,613,641,650,659,688,693,698,720,762,809,814,840,890,939,944,981,1010,1024,1043,1079,1112,1120,1142,1160,1172,1202,1210,1215,1220,1229,1244,1250,1255,1260,1268,1279,1326,1362,1392,1401,1407,1415,1434,1440,1451,1487,1498,1503,1508,1524],{"__ignoreMap":136},[140,141,144],"span",{"class":142,"line":143},"line",1,[140,145,147],{"class":146},"sJ8bj","# src\u002Fmytool\u002Fcli.py\n",[140,149,151,155,159,162],{"class":142,"line":150},2,[140,152,154],{"class":153},"szBVR","from",[140,156,158],{"class":157},"sj4cs"," __future__",[140,160,161],{"class":153}," import",[140,163,165],{"class":164},"sVt8B"," annotations\n",[140,167,169],{"class":142,"line":168},3,[140,170,172],{"emptyLinePlaceholder":171},true,"\n",[140,174,176,179],{"class":142,"line":175},4,[140,177,178],{"class":153},"import",[140,180,181],{"class":164}," json\n",[140,183,185,187],{"class":142,"line":184},5,[140,186,178],{"class":153},[140,188,189],{"class":164}," shutil\n",[140,191,193,195,198,200],{"class":142,"line":192},6,[140,194,154],{"class":153},[140,196,197],{"class":164}," dataclasses ",[140,199,178],{"class":153},[140,201,202],{"class":164}," asdict, dataclass\n",[140,204,206,208,211,213],{"class":142,"line":205},7,[140,207,154],{"class":153},[140,209,210],{"class":164}," typing ",[140,212,178],{"class":153},[140,214,215],{"class":164}," Annotated\n",[140,217,219],{"class":142,"line":218},8,[140,220,172],{"emptyLinePlaceholder":171},[140,222,224,226],{"class":142,"line":223},9,[140,225,178],{"class":153},[140,227,228],{"class":164}," typer\n",[140,230,232,234,237,239],{"class":142,"line":231},10,[140,233,154],{"class":153},[140,235,236],{"class":164}," rich.console ",[140,238,178],{"class":153},[140,240,241],{"class":164}," Console\n",[140,243,245,247,250,252],{"class":142,"line":244},11,[140,246,154],{"class":153},[140,248,249],{"class":164}," rich.table ",[140,251,178],{"class":153},[140,253,254],{"class":164}," Table\n",[140,256,258],{"class":142,"line":257},12,[140,259,172],{"emptyLinePlaceholder":171},[140,261,263,266,269],{"class":142,"line":262},13,[140,264,265],{"class":164},"app ",[140,267,268],{"class":153},"=",[140,270,271],{"class":164}," typer.Typer()\n",[140,273,275],{"class":142,"line":274},14,[140,276,172],{"emptyLinePlaceholder":171},[140,278,280],{"class":142,"line":279},15,[140,281,172],{"emptyLinePlaceholder":171},[140,283,285],{"class":142,"line":284},16,[140,286,288],{"class":287},"sScJk","@dataclass\n",[140,290,292,295,298],{"class":142,"line":291},17,[140,293,294],{"class":153},"class",[140,296,297],{"class":287}," Build",[140,299,300],{"class":164},":\n",[140,302,304,307,310],{"class":142,"line":303},18,[140,305,306],{"class":157},"    id",[140,308,309],{"class":164},": ",[140,311,312],{"class":157},"str\n",[140,314,316,319],{"class":142,"line":315},19,[140,317,318],{"class":164},"    project: ",[140,320,312],{"class":157},[140,322,324,327],{"class":142,"line":323},20,[140,325,326],{"class":164},"    status: ",[140,328,312],{"class":157},[140,330,332,335],{"class":142,"line":331},21,[140,333,334],{"class":164},"    branch: ",[140,336,312],{"class":157},[140,338,340,343],{"class":142,"line":339},22,[140,341,342],{"class":164},"    started: ",[140,344,312],{"class":157},[140,346,348,351],{"class":142,"line":347},23,[140,349,350],{"class":164},"    commit_message: ",[140,352,312],{"class":157},[140,354,356],{"class":142,"line":355},24,[140,357,172],{"emptyLinePlaceholder":171},[140,359,361],{"class":142,"line":360},25,[140,362,172],{"emptyLinePlaceholder":171},[140,364,366,369,372],{"class":142,"line":365},26,[140,367,368],{"class":157},"BUILDS",[140,370,371],{"class":153}," =",[140,373,374],{"class":164}," [\n",[140,376,378,381,385,388,391,393,396,398,401,403,406],{"class":142,"line":377},27,[140,379,380],{"class":164},"    Build(",[140,382,384],{"class":383},"sZZnC","\"4411\"",[140,386,387],{"class":164},", ",[140,389,390],{"class":383},"\"web\"",[140,392,387],{"class":164},[140,394,395],{"class":383},"\"passed\"",[140,397,387],{"class":164},[140,399,400],{"class":383},"\"feature\u002Fnew-navigation-menu\"",[140,402,387],{"class":164},[140,404,405],{"class":383},"\"2m ago\"",[140,407,408],{"class":164},",\n",[140,410,412,415],{"class":142,"line":411},28,[140,413,414],{"class":383},"          \"Rework the navigation menu so keyboard users can reach every section\"",[140,416,417],{"class":164},"),\n",[140,419,421,423,426,428,431,433,436,438,441,443,446,448,451],{"class":142,"line":420},29,[140,422,380],{"class":164},[140,424,425],{"class":383},"\"4410\"",[140,427,387],{"class":164},[140,429,430],{"class":383},"\"billing\"",[140,432,387],{"class":164},[140,434,435],{"class":383},"\"failed\"",[140,437,387],{"class":164},[140,439,440],{"class":383},"\"main\"",[140,442,387],{"class":164},[140,444,445],{"class":383},"\"9m ago\"",[140,447,387],{"class":164},[140,449,450],{"class":383},"\"Bump httpx\"",[140,452,417],{"class":164},[140,454,456],{"class":142,"line":455},30,[140,457,458],{"class":164},"]\n",[140,460,462],{"class":142,"line":461},31,[140,463,172],{"emptyLinePlaceholder":171},[140,465,467],{"class":142,"line":466},32,[140,468,469],{"class":146},"# (header, attribute, minimum terminal width at which the column is shown)\n",[140,471,473,475,477],{"class":142,"line":472},33,[140,474,59],{"class":157},[140,476,371],{"class":153},[140,478,374],{"class":164},[140,480,482,485,488,490,493,495,498],{"class":142,"line":481},34,[140,483,484],{"class":164},"    (",[140,486,487],{"class":383},"\"ID\"",[140,489,387],{"class":164},[140,491,492],{"class":383},"\"id\"",[140,494,387],{"class":164},[140,496,497],{"class":157},"0",[140,499,417],{"class":164},[140,501,503,505,508,510,513,515,517],{"class":142,"line":502},35,[140,504,484],{"class":164},[140,506,507],{"class":383},"\"PROJECT\"",[140,509,387],{"class":164},[140,511,512],{"class":383},"\"project\"",[140,514,387],{"class":164},[140,516,497],{"class":157},[140,518,417],{"class":164},[140,520,522,524,527,529,532,534,536],{"class":142,"line":521},36,[140,523,484],{"class":164},[140,525,526],{"class":383},"\"STATUS\"",[140,528,387],{"class":164},[140,530,531],{"class":383},"\"status\"",[140,533,387],{"class":164},[140,535,497],{"class":157},[140,537,417],{"class":164},[140,539,541,543,546,548,551,553,556],{"class":142,"line":540},37,[140,542,484],{"class":164},[140,544,545],{"class":383},"\"BRANCH\"",[140,547,387],{"class":164},[140,549,550],{"class":383},"\"branch\"",[140,552,387],{"class":164},[140,554,555],{"class":157},"50",[140,557,417],{"class":164},[140,559,561,563,566,568,571,573,576],{"class":142,"line":560},38,[140,562,484],{"class":164},[140,564,565],{"class":383},"\"STARTED\"",[140,567,387],{"class":164},[140,569,570],{"class":383},"\"started\"",[140,572,387],{"class":164},[140,574,575],{"class":157},"70",[140,577,417],{"class":164},[140,579,581,583,586,588,591,593,596],{"class":142,"line":580},39,[140,582,484],{"class":164},[140,584,585],{"class":383},"\"MESSAGE\"",[140,587,387],{"class":164},[140,589,590],{"class":383},"\"commit_message\"",[140,592,387],{"class":164},[140,594,595],{"class":157},"100",[140,597,417],{"class":164},[140,599,601],{"class":142,"line":600},40,[140,602,458],{"class":164},[140,604,606],{"class":142,"line":605},41,[140,607,172],{"emptyLinePlaceholder":171},[140,609,611],{"class":142,"line":610},42,[140,612,172],{"emptyLinePlaceholder":171},[140,614,616,619,622,625,628,631,634,637,639],{"class":142,"line":615},43,[140,617,618],{"class":153},"def",[140,620,621],{"class":287}," terminal_width",[140,623,624],{"class":164},"(explicit: ",[140,626,627],{"class":157},"int",[140,629,630],{"class":153}," |",[140,632,633],{"class":157}," None",[140,635,636],{"class":164},") -> ",[140,638,627],{"class":157},[140,640,300],{"class":164},[140,642,644,647],{"class":142,"line":643},44,[140,645,646],{"class":153},"    if",[140,648,649],{"class":164}," explicit:\n",[140,651,653,656],{"class":142,"line":652},45,[140,654,655],{"class":153},"        return",[140,657,658],{"class":164}," explicit\n",[140,660,662,665,668,672,674,677,680,682,685],{"class":142,"line":661},46,[140,663,664],{"class":153},"    return",[140,666,667],{"class":164}," shutil.get_terminal_size(",[140,669,671],{"class":670},"s4XuR","fallback",[140,673,268],{"class":153},[140,675,676],{"class":164},"(",[140,678,679],{"class":157},"80",[140,681,387],{"class":164},[140,683,684],{"class":157},"24",[140,686,687],{"class":164},")).columns\n",[140,689,691],{"class":142,"line":690},47,[140,692,172],{"emptyLinePlaceholder":171},[140,694,696],{"class":142,"line":695},48,[140,697,172],{"emptyLinePlaceholder":171},[140,699,701,703,706,709,711,714,717],{"class":142,"line":700},49,[140,702,618],{"class":153},[140,704,705],{"class":287}," build_table",[140,707,708],{"class":164},"(rows: list[Build], width: ",[140,710,627],{"class":157},[140,712,713],{"class":164},", wide: ",[140,715,716],{"class":157},"bool",[140,718,719],{"class":164},") -> Table:\n",[140,721,723,726,728,731,734,736,739,741,744,746,749,751,754,756,759],{"class":142,"line":722},50,[140,724,725],{"class":164},"    table ",[140,727,268],{"class":153},[140,729,730],{"class":164}," Table(",[140,732,733],{"class":670},"box",[140,735,268],{"class":153},[140,737,738],{"class":157},"None",[140,740,387],{"class":164},[140,742,743],{"class":670},"pad_edge",[140,745,268],{"class":153},[140,747,748],{"class":157},"False",[140,750,387],{"class":164},[140,752,753],{"class":670},"header_style",[140,755,268],{"class":153},[140,757,758],{"class":383},"\"bold\"",[140,760,761],{"class":164},")\n",[140,763,765,768,770,773,776,779,782,785,788,791,794,797,800,803,806],{"class":142,"line":764},51,[140,766,767],{"class":164},"    shown ",[140,769,268],{"class":153},[140,771,772],{"class":164}," [c ",[140,774,775],{"class":153},"for",[140,777,778],{"class":164}," c ",[140,780,781],{"class":153},"in",[140,783,784],{"class":157}," COLUMNS",[140,786,787],{"class":153}," if",[140,789,790],{"class":164}," wide ",[140,792,793],{"class":153},"or",[140,795,796],{"class":164}," width ",[140,798,799],{"class":153},">=",[140,801,802],{"class":164}," c[",[140,804,805],{"class":157},"2",[140,807,808],{"class":164},"]]\n",[140,810,812],{"class":142,"line":811},52,[140,813,172],{"emptyLinePlaceholder":171},[140,815,817,820,823,826,829,832,834,836,838],{"class":142,"line":816},53,[140,818,819],{"class":153},"    def",[140,821,822],{"class":287}," natural",[140,824,825],{"class":164},"(attr: ",[140,827,828],{"class":157},"str",[140,830,831],{"class":164},", header: ",[140,833,828],{"class":157},[140,835,636],{"class":164},[140,837,627],{"class":157},[140,839,300],{"class":164},[140,841,843,846,848,851,854,857,860,863,866,868,870,872,874,877,880,882,885,887],{"class":142,"line":842},54,[140,844,845],{"class":164},"        longest ",[140,847,268],{"class":153},[140,849,850],{"class":157}," max",[140,852,853],{"class":164},"([",[140,855,856],{"class":157},"len",[140,858,859],{"class":164},"(header)] ",[140,861,862],{"class":153},"+",[140,864,865],{"class":164}," [",[140,867,856],{"class":157},[140,869,676],{"class":164},[140,871,828],{"class":157},[140,873,676],{"class":164},[140,875,876],{"class":157},"getattr",[140,878,879],{"class":164},"(r, attr))) ",[140,881,775],{"class":153},[140,883,884],{"class":164}," r ",[140,886,781],{"class":153},[140,888,889],{"class":164}," rows])\n",[140,891,893,895,898,901,903,905,908,910,913,915,917,919,921,923,926,929,932,935,937],{"class":142,"line":892},55,[140,894,655],{"class":153},[140,896,897],{"class":164}," longest ",[140,899,900],{"class":153},"if",[140,902,790],{"class":164},[140,904,793],{"class":153},[140,906,907],{"class":164}," attr ",[140,909,781],{"class":153},[140,911,912],{"class":164}," (",[140,914,492],{"class":383},[140,916,387],{"class":164},[140,918,512],{"class":383},[140,920,387],{"class":164},[140,922,531],{"class":383},[140,924,925],{"class":164},") ",[140,927,928],{"class":153},"else",[140,930,931],{"class":157}," min",[140,933,934],{"class":164},"(longest, ",[140,936,684],{"class":157},[140,938,761],{"class":164},[140,940,942],{"class":142,"line":941},56,[140,943,172],{"emptyLinePlaceholder":171},[140,945,947,950,952,955,958,960,963,965,968,970,973,976,979],{"class":142,"line":946},57,[140,948,949],{"class":164},"    fixed ",[140,951,268],{"class":153},[140,953,954],{"class":157}," sum",[140,956,957],{"class":164},"(natural(a, h) ",[140,959,775],{"class":153},[140,961,962],{"class":164}," h, a, _ ",[140,964,781],{"class":153},[140,966,967],{"class":164}," shown ",[140,969,900],{"class":153},[140,971,972],{"class":164}," a ",[140,974,975],{"class":153},"!=",[140,977,978],{"class":383}," \"commit_message\"",[140,980,761],{"class":164},[140,982,984,987,989,992,995,997,999,1002,1005,1008],{"class":142,"line":983},58,[140,985,986],{"class":164},"    gutters ",[140,988,268],{"class":153},[140,990,991],{"class":157}," 2",[140,993,994],{"class":153}," *",[140,996,912],{"class":164},[140,998,856],{"class":157},[140,1000,1001],{"class":164},"(shown) ",[140,1003,1004],{"class":153},"-",[140,1006,1007],{"class":157}," 1",[140,1009,761],{"class":164},[140,1011,1013,1016,1019,1021],{"class":142,"line":1012},59,[140,1014,1015],{"class":153},"    for",[140,1017,1018],{"class":164}," header, attr, _ ",[140,1020,781],{"class":153},[140,1022,1023],{"class":164}," shown:\n",[140,1025,1027,1030,1032,1035,1037,1040],{"class":142,"line":1026},60,[140,1028,1029],{"class":153},"        if",[140,1031,907],{"class":164},[140,1033,1034],{"class":153},"==",[140,1036,978],{"class":383},[140,1038,1039],{"class":164},":                   ",[140,1041,1042],{"class":146},"# the flexible column gets what is left\n",[140,1044,1046,1049,1051,1053,1055,1057,1059,1061,1063,1066,1069,1071,1074,1076],{"class":142,"line":1045},61,[140,1047,1048],{"class":164},"            room ",[140,1050,268],{"class":153},[140,1052,633],{"class":157},[140,1054,787],{"class":153},[140,1056,790],{"class":164},[140,1058,928],{"class":153},[140,1060,850],{"class":157},[140,1062,676],{"class":164},[140,1064,1065],{"class":157},"20",[140,1067,1068],{"class":164},", width ",[140,1070,1004],{"class":153},[140,1072,1073],{"class":164}," fixed ",[140,1075,1004],{"class":153},[140,1077,1078],{"class":164}," gutters)\n",[140,1080,1082,1085,1088,1090,1093,1095,1098,1101,1104,1107,1109],{"class":142,"line":1081},62,[140,1083,1084],{"class":164},"            table.add_column(header, ",[140,1086,1087],{"class":670},"overflow",[140,1089,268],{"class":153},[140,1091,1092],{"class":383},"\"ellipsis\"",[140,1094,387],{"class":164},[140,1096,1097],{"class":670},"no_wrap",[140,1099,1100],{"class":153},"=not",[140,1102,1103],{"class":164}," wide, ",[140,1105,1106],{"class":670},"max_width",[140,1108,268],{"class":153},[140,1110,1111],{"class":164},"room)\n",[140,1113,1115,1118],{"class":142,"line":1114},63,[140,1116,1117],{"class":153},"        else",[140,1119,300],{"class":164},[140,1121,1123,1125,1127,1129,1131,1133,1135,1137,1140],{"class":142,"line":1122},64,[140,1124,1084],{"class":164},[140,1126,1087],{"class":670},[140,1128,268],{"class":153},[140,1130,1092],{"class":383},[140,1132,387],{"class":164},[140,1134,1097],{"class":670},[140,1136,268],{"class":153},[140,1138,1139],{"class":157},"True",[140,1141,408],{"class":164},[140,1143,1145,1148,1150,1153,1155,1157],{"class":142,"line":1144},65,[140,1146,1147],{"class":670},"                             min_width",[140,1149,268],{"class":153},[140,1151,1152],{"class":164},"natural(attr, header), ",[140,1154,1106],{"class":670},[140,1156,268],{"class":153},[140,1158,1159],{"class":164},"natural(attr, header))\n",[140,1161,1163,1165,1167,1169],{"class":142,"line":1162},66,[140,1164,1015],{"class":153},[140,1166,884],{"class":164},[140,1168,781],{"class":153},[140,1170,1171],{"class":164}," rows:\n",[140,1173,1175,1178,1181,1183,1185,1187,1189,1192,1194,1197,1199],{"class":142,"line":1174},67,[140,1176,1177],{"class":164},"        table.add_row(",[140,1179,1180],{"class":153},"*",[140,1182,676],{"class":164},[140,1184,828],{"class":157},[140,1186,676],{"class":164},[140,1188,876],{"class":157},[140,1190,1191],{"class":164},"(r, attr)) ",[140,1193,775],{"class":153},[140,1195,1196],{"class":164}," _, attr, _ ",[140,1198,781],{"class":153},[140,1200,1201],{"class":164}," shown))\n",[140,1203,1205,1207],{"class":142,"line":1204},68,[140,1206,664],{"class":153},[140,1208,1209],{"class":164}," table\n",[140,1211,1213],{"class":142,"line":1212},69,[140,1214,172],{"emptyLinePlaceholder":171},[140,1216,1218],{"class":142,"line":1217},70,[140,1219,172],{"emptyLinePlaceholder":171},[140,1221,1223,1226],{"class":142,"line":1222},71,[140,1224,1225],{"class":287},"@app.callback",[140,1227,1228],{"class":164},"()\n",[140,1230,1232,1234,1237,1240,1242],{"class":142,"line":1231},72,[140,1233,618],{"class":153},[140,1235,1236],{"class":287}," main",[140,1238,1239],{"class":164},"() -> ",[140,1241,738],{"class":157},[140,1243,300],{"class":164},[140,1245,1247],{"class":142,"line":1246},73,[140,1248,1249],{"class":383},"    \"\"\"Build history.\"\"\"\n",[140,1251,1253],{"class":142,"line":1252},74,[140,1254,172],{"emptyLinePlaceholder":171},[140,1256,1258],{"class":142,"line":1257},75,[140,1259,172],{"emptyLinePlaceholder":171},[140,1261,1263,1266],{"class":142,"line":1262},76,[140,1264,1265],{"class":287},"@app.command",[140,1267,1228],{"class":164},[140,1269,1271,1273,1276],{"class":142,"line":1270},77,[140,1272,618],{"class":153},[140,1274,1275],{"class":287}," builds",[140,1277,1278],{"class":164},"(\n",[140,1280,1282,1285,1287,1289,1291,1294,1297,1299,1302,1304,1307,1309,1312,1314,1317,1320,1322,1324],{"class":142,"line":1281},78,[140,1283,1284],{"class":164},"    width: Annotated[",[140,1286,627],{"class":157},[140,1288,630],{"class":153},[140,1290,633],{"class":157},[140,1292,1293],{"class":164},", typer.Option(",[140,1295,1296],{"class":383},"\"--width\"",[140,1298,387],{"class":164},[140,1300,1301],{"class":670},"min",[140,1303,268],{"class":153},[140,1305,1306],{"class":157},"40",[140,1308,387],{"class":164},[140,1310,1311],{"class":670},"help",[140,1313,268],{"class":153},[140,1315,1316],{"class":383},"\"Layout width (default: terminal).\"",[140,1318,1319],{"class":164},")] ",[140,1321,268],{"class":153},[140,1323,633],{"class":157},[140,1325,408],{"class":164},[140,1327,1329,1332,1334,1336,1339,1341,1344,1346,1348,1350,1353,1355,1357,1360],{"class":142,"line":1328},79,[140,1330,1331],{"class":164},"    wide: Annotated[",[140,1333,716],{"class":157},[140,1335,1293],{"class":164},[140,1337,1338],{"class":383},"\"--wide\"",[140,1340,387],{"class":164},[140,1342,1343],{"class":383},"\"-w\"",[140,1345,387],{"class":164},[140,1347,1311],{"class":670},[140,1349,268],{"class":153},[140,1351,1352],{"class":383},"\"Show every column in full.\"",[140,1354,1319],{"class":164},[140,1356,268],{"class":153},[140,1358,1359],{"class":157}," False",[140,1361,408],{"class":164},[140,1363,1365,1368,1370,1372,1375,1377,1379,1381,1384,1386,1388,1390],{"class":142,"line":1364},80,[140,1366,1367],{"class":164},"    as_json: Annotated[",[140,1369,716],{"class":157},[140,1371,1293],{"class":164},[140,1373,1374],{"class":383},"\"--json\"",[140,1376,387],{"class":164},[140,1378,1311],{"class":670},[140,1380,268],{"class":153},[140,1382,1383],{"class":383},"\"Machine-readable output, never truncated.\"",[140,1385,1319],{"class":164},[140,1387,268],{"class":153},[140,1389,1359],{"class":157},[140,1391,408],{"class":164},[140,1393,1395,1397,1399],{"class":142,"line":1394},81,[140,1396,636],{"class":164},[140,1398,738],{"class":157},[140,1400,300],{"class":164},[140,1402,1404],{"class":142,"line":1403},82,[140,1405,1406],{"class":383},"    \"\"\"List recent builds, fitted to the terminal.\"\"\"\n",[140,1408,1410,1412],{"class":142,"line":1409},83,[140,1411,646],{"class":153},[140,1413,1414],{"class":164}," as_json:\n",[140,1416,1418,1421,1423,1426,1428,1431],{"class":142,"line":1417},84,[140,1419,1420],{"class":164},"        typer.echo(json.dumps([asdict(b) ",[140,1422,775],{"class":153},[140,1424,1425],{"class":164}," b ",[140,1427,781],{"class":153},[140,1429,1430],{"class":157}," BUILDS",[140,1432,1433],{"class":164},"]))\n",[140,1435,1437],{"class":142,"line":1436},85,[140,1438,1439],{"class":153},"        return\n",[140,1441,1443,1446,1448],{"class":142,"line":1442},86,[140,1444,1445],{"class":164},"    cols ",[140,1447,268],{"class":153},[140,1449,1450],{"class":164}," terminal_width(width)\n",[140,1452,1454,1457,1459,1462,1464,1466,1469,1471,1473,1475,1478,1481,1483,1485],{"class":142,"line":1453},87,[140,1455,1456],{"class":164},"    console ",[140,1458,268],{"class":153},[140,1460,1461],{"class":164}," Console(",[140,1463,70],{"class":670},[140,1465,268],{"class":153},[140,1467,1468],{"class":157},"10_000",[140,1470,787],{"class":153},[140,1472,790],{"class":164},[140,1474,928],{"class":153},[140,1476,1477],{"class":164}," cols, ",[140,1479,1480],{"class":670},"highlight",[140,1482,268],{"class":153},[140,1484,748],{"class":157},[140,1486,761],{"class":164},[140,1488,1490,1493,1495],{"class":142,"line":1489},88,[140,1491,1492],{"class":164},"    console.print(build_table(",[140,1494,368],{"class":157},[140,1496,1497],{"class":164},", cols, wide))\n",[140,1499,1501],{"class":142,"line":1500},89,[140,1502,172],{"emptyLinePlaceholder":171},[140,1504,1506],{"class":142,"line":1505},90,[140,1507,172],{"emptyLinePlaceholder":171},[140,1509,1511,1513,1516,1519,1522],{"class":142,"line":1510},91,[140,1512,900],{"class":153},[140,1514,1515],{"class":157}," __name__",[140,1517,1518],{"class":153}," ==",[140,1520,1521],{"class":383}," \"__main__\"",[140,1523,300],{"class":164},[140,1525,1527],{"class":142,"line":1526},92,[140,1528,1529],{"class":164},"    app()\n",[10,1531,1532],{},"How the layout works:",[34,1534,1535,1541,1552,1562,1571,1586],{},[37,1536,1537,1540],{},[87,1538,1539],{},"Each column carries a minimum terminal width"," at which it appears: branch at 50 columns, start time at 70, the message at 100. Below those, the columns are dropped entirely — a narrow terminal still shows a clean table of what matters.",[37,1542,1543,912,1546,17,1549,1551],{},[87,1544,1545],{},"Essential columns are sized to their content",[14,1547,1548],{},"min_width",[14,1550,1106],{}," both set to the natural width), so Rich never squeezes the ID or status into an ellipsis.",[37,1553,1554,1557,1558,1561],{},[87,1555,1556],{},"Useful columns are capped at 24 characters"," with ",[14,1559,1560],{},"overflow=\"ellipsis\"",", so one long branch name cannot push everything else off screen.",[37,1563,1564,1567,1568,1570],{},[87,1565,1566],{},"The message column gets the remaining space."," Its ",[14,1569,1106],{}," is computed from the terminal width minus the fixed columns and gutters, so it fills the line exactly and truncates with an ellipsis only when it must.",[37,1572,1573,1578,1579,1582,1583,27],{},[87,1574,1575,1577],{},[14,1576,16],{}," removes all limits",": every column shown in full, on a virtually unlimited console width, so lines may exceed the terminal — the user asked for completeness over fit, as with ",[14,1580,1581],{},"ps -ww"," or ",[14,1584,1585],{},"kubectl get -o wide",[37,1587,1588,1594],{},[87,1589,1590,1593],{},[14,1591,1592],{},"--json"," bypasses layout entirely."," Machine output is complete regardless of width; truncating data meant for another program would be a bug.",[48,1596],{"name":1597},"tw-terminal",[29,1599,1601],{"id":1600},"ux-considerations","UX considerations",[34,1603,1604,1610,1616,1629,1635],{},[37,1605,1606,1609],{},[87,1607,1608],{},"Show that something was cut."," An ellipsis tells users there is more; silent truncation makes them think the value is shorter than it is — dangerous for paths and IDs.",[37,1611,1612,1615],{},[87,1613,1614],{},"Never truncate identifiers users copy."," An ID someone will paste into another command must appear in full, which is why it is an essential column here. If IDs are long (UUIDs), consider showing a unique prefix and accepting prefixes as input, as git does with commit hashes.",[37,1617,1618,1621,1622,1625,1626,1628],{},[87,1619,1620],{},"Keep row count predictable."," No-wrap columns keep one row per item, which is what people scan and what ",[14,1623,1624],{},"wc -l"," counts. Wrap only the flexible column, and only in ",[14,1627,16],{}," mode.",[37,1630,1631,1634],{},[87,1632,1633],{},"Point to the escape hatch."," When columns were dropped, a short footer on stderr — \"(narrow terminal: use --wide for all columns)\" — teaches the option at the moment it helps.",[37,1636,1637,1640,1641,1644,1645,1648],{},[87,1638,1639],{},"Wrap prose to the width too."," Help text and messages longer than a line read better wrapped at word boundaries; Rich wraps ",[14,1642,1643],{},"console.print"," output automatically, and ",[14,1646,1647],{},"textwrap.fill(text, width)"," does it for plain strings.",[29,1650,1652],{"id":1651},"testing-the-behaviour","Testing the behaviour",[10,1654,1655,1656,1658,1659,1661,1662,1665,1666,1669],{},"Because ",[14,1657,55],{}," and Rich both honour ",[14,1660,59],{},", tests can exercise every width through ",[14,1663,1664],{},"CliRunner","'s ",[14,1667,1668],{},"env="," without a real terminal:",[131,1671,1673],{"className":133,"code":1672,"language":135,"meta":136,"style":136},"# tests\u002Ftest_width.py\nimport json\n\nimport pytest\nfrom typer.testing import CliRunner\n\nfrom mytool.cli import BUILDS, app\n\nrunner = CliRunner()\n\n\ndef lines(result):\n    return [l for l in result.output.splitlines() if l.strip()]\n\n\n@pytest.mark.parametrize(\"cols\", [40, 60, 80, 120])\ndef test_output_fits_the_width(cols):\n    result = runner.invoke(app, [\"builds\"], env={\"COLUMNS\": str(cols)})\n    assert result.exit_code == 0\n    assert all(len(l) \u003C= cols for l in lines(result)), result.output\n\n\ndef test_narrow_drops_low_priority_columns():\n    out = runner.invoke(app, [\"builds\", \"--width\", \"45\"]).output\n    assert \"BRANCH\" not in out and \"STATUS\" in out\n\n\ndef test_long_values_are_truncated_with_an_ellipsis():\n    out = runner.invoke(app, [\"builds\", \"--width\", \"60\"]).output\n    assert \"…\" in out and \"feature\u002Fnew-navigation-menu\" not in out\n\n\ndef test_wide_shows_everything_in_full():\n    out = runner.invoke(app, [\"builds\", \"--wide\"]).output\n    assert \"feature\u002Fnew-navigation-menu\" in out\n    assert \"keyboard users can reach every section\" in out\n\n\ndef test_json_is_never_truncated():\n    result = runner.invoke(app, [\"builds\", \"--json\"], env={\"COLUMNS\": \"40\"})\n    assert json.loads(result.output)[0][\"branch\"] == BUILDS[0].branch\n",[14,1674,1675,1680,1686,1690,1697,1709,1713,1727,1731,1741,1745,1749,1759,1781,1785,1789,1821,1831,1865,1878,1907,1911,1915,1925,1948,1975,1979,1983,1992,2013,2035,2039,2043,2052,2068,2078,2089,2093,2097,2106,2138],{"__ignoreMap":136},[140,1676,1677],{"class":142,"line":143},[140,1678,1679],{"class":146},"# tests\u002Ftest_width.py\n",[140,1681,1682,1684],{"class":142,"line":150},[140,1683,178],{"class":153},[140,1685,181],{"class":164},[140,1687,1688],{"class":142,"line":168},[140,1689,172],{"emptyLinePlaceholder":171},[140,1691,1692,1694],{"class":142,"line":175},[140,1693,178],{"class":153},[140,1695,1696],{"class":164}," pytest\n",[140,1698,1699,1701,1704,1706],{"class":142,"line":184},[140,1700,154],{"class":153},[140,1702,1703],{"class":164}," typer.testing ",[140,1705,178],{"class":153},[140,1707,1708],{"class":164}," CliRunner\n",[140,1710,1711],{"class":142,"line":192},[140,1712,172],{"emptyLinePlaceholder":171},[140,1714,1715,1717,1720,1722,1724],{"class":142,"line":205},[140,1716,154],{"class":153},[140,1718,1719],{"class":164}," mytool.cli ",[140,1721,178],{"class":153},[140,1723,1430],{"class":157},[140,1725,1726],{"class":164},", app\n",[140,1728,1729],{"class":142,"line":218},[140,1730,172],{"emptyLinePlaceholder":171},[140,1732,1733,1736,1738],{"class":142,"line":223},[140,1734,1735],{"class":164},"runner ",[140,1737,268],{"class":153},[140,1739,1740],{"class":164}," CliRunner()\n",[140,1742,1743],{"class":142,"line":231},[140,1744,172],{"emptyLinePlaceholder":171},[140,1746,1747],{"class":142,"line":244},[140,1748,172],{"emptyLinePlaceholder":171},[140,1750,1751,1753,1756],{"class":142,"line":257},[140,1752,618],{"class":153},[140,1754,1755],{"class":287}," lines",[140,1757,1758],{"class":164},"(result):\n",[140,1760,1761,1763,1766,1768,1771,1773,1776,1778],{"class":142,"line":262},[140,1762,664],{"class":153},[140,1764,1765],{"class":164}," [l ",[140,1767,775],{"class":153},[140,1769,1770],{"class":164}," l ",[140,1772,781],{"class":153},[140,1774,1775],{"class":164}," result.output.splitlines() ",[140,1777,900],{"class":153},[140,1779,1780],{"class":164}," l.strip()]\n",[140,1782,1783],{"class":142,"line":274},[140,1784,172],{"emptyLinePlaceholder":171},[140,1786,1787],{"class":142,"line":279},[140,1788,172],{"emptyLinePlaceholder":171},[140,1790,1791,1794,1796,1799,1802,1804,1806,1809,1811,1813,1815,1818],{"class":142,"line":284},[140,1792,1793],{"class":287},"@pytest.mark.parametrize",[140,1795,676],{"class":164},[140,1797,1798],{"class":383},"\"cols\"",[140,1800,1801],{"class":164},", [",[140,1803,1306],{"class":157},[140,1805,387],{"class":164},[140,1807,1808],{"class":157},"60",[140,1810,387],{"class":164},[140,1812,679],{"class":157},[140,1814,387],{"class":164},[140,1816,1817],{"class":157},"120",[140,1819,1820],{"class":164},"])\n",[140,1822,1823,1825,1828],{"class":142,"line":291},[140,1824,618],{"class":153},[140,1826,1827],{"class":287}," test_output_fits_the_width",[140,1829,1830],{"class":164},"(cols):\n",[140,1832,1833,1836,1838,1841,1844,1847,1850,1852,1855,1858,1860,1862],{"class":142,"line":303},[140,1834,1835],{"class":164},"    result ",[140,1837,268],{"class":153},[140,1839,1840],{"class":164}," runner.invoke(app, [",[140,1842,1843],{"class":383},"\"builds\"",[140,1845,1846],{"class":164},"], ",[140,1848,1849],{"class":670},"env",[140,1851,268],{"class":153},[140,1853,1854],{"class":164},"{",[140,1856,1857],{"class":383},"\"COLUMNS\"",[140,1859,309],{"class":164},[140,1861,828],{"class":157},[140,1863,1864],{"class":164},"(cols)})\n",[140,1866,1867,1870,1873,1875],{"class":142,"line":315},[140,1868,1869],{"class":153},"    assert",[140,1871,1872],{"class":164}," result.exit_code ",[140,1874,1034],{"class":153},[140,1876,1877],{"class":157}," 0\n",[140,1879,1880,1882,1885,1887,1889,1892,1895,1898,1900,1902,1904],{"class":142,"line":323},[140,1881,1869],{"class":153},[140,1883,1884],{"class":157}," all",[140,1886,676],{"class":164},[140,1888,856],{"class":157},[140,1890,1891],{"class":164},"(l) ",[140,1893,1894],{"class":153},"\u003C=",[140,1896,1897],{"class":164}," cols ",[140,1899,775],{"class":153},[140,1901,1770],{"class":164},[140,1903,781],{"class":153},[140,1905,1906],{"class":164}," lines(result)), result.output\n",[140,1908,1909],{"class":142,"line":331},[140,1910,172],{"emptyLinePlaceholder":171},[140,1912,1913],{"class":142,"line":339},[140,1914,172],{"emptyLinePlaceholder":171},[140,1916,1917,1919,1922],{"class":142,"line":347},[140,1918,618],{"class":153},[140,1920,1921],{"class":287}," test_narrow_drops_low_priority_columns",[140,1923,1924],{"class":164},"():\n",[140,1926,1927,1930,1932,1934,1936,1938,1940,1942,1945],{"class":142,"line":355},[140,1928,1929],{"class":164},"    out ",[140,1931,268],{"class":153},[140,1933,1840],{"class":164},[140,1935,1843],{"class":383},[140,1937,387],{"class":164},[140,1939,1296],{"class":383},[140,1941,387],{"class":164},[140,1943,1944],{"class":383},"\"45\"",[140,1946,1947],{"class":164},"]).output\n",[140,1949,1950,1952,1955,1958,1961,1964,1967,1970,1972],{"class":142,"line":360},[140,1951,1869],{"class":153},[140,1953,1954],{"class":383}," \"BRANCH\"",[140,1956,1957],{"class":153}," not",[140,1959,1960],{"class":153}," in",[140,1962,1963],{"class":164}," out ",[140,1965,1966],{"class":153},"and",[140,1968,1969],{"class":383}," \"STATUS\"",[140,1971,1960],{"class":153},[140,1973,1974],{"class":164}," out\n",[140,1976,1977],{"class":142,"line":365},[140,1978,172],{"emptyLinePlaceholder":171},[140,1980,1981],{"class":142,"line":377},[140,1982,172],{"emptyLinePlaceholder":171},[140,1984,1985,1987,1990],{"class":142,"line":411},[140,1986,618],{"class":153},[140,1988,1989],{"class":287}," test_long_values_are_truncated_with_an_ellipsis",[140,1991,1924],{"class":164},[140,1993,1994,1996,1998,2000,2002,2004,2006,2008,2011],{"class":142,"line":420},[140,1995,1929],{"class":164},[140,1997,268],{"class":153},[140,1999,1840],{"class":164},[140,2001,1843],{"class":383},[140,2003,387],{"class":164},[140,2005,1296],{"class":383},[140,2007,387],{"class":164},[140,2009,2010],{"class":383},"\"60\"",[140,2012,1947],{"class":164},[140,2014,2015,2017,2020,2022,2024,2026,2029,2031,2033],{"class":142,"line":455},[140,2016,1869],{"class":153},[140,2018,2019],{"class":383}," \"…\"",[140,2021,1960],{"class":153},[140,2023,1963],{"class":164},[140,2025,1966],{"class":153},[140,2027,2028],{"class":383}," \"feature\u002Fnew-navigation-menu\"",[140,2030,1957],{"class":153},[140,2032,1960],{"class":153},[140,2034,1974],{"class":164},[140,2036,2037],{"class":142,"line":461},[140,2038,172],{"emptyLinePlaceholder":171},[140,2040,2041],{"class":142,"line":466},[140,2042,172],{"emptyLinePlaceholder":171},[140,2044,2045,2047,2050],{"class":142,"line":472},[140,2046,618],{"class":153},[140,2048,2049],{"class":287}," test_wide_shows_everything_in_full",[140,2051,1924],{"class":164},[140,2053,2054,2056,2058,2060,2062,2064,2066],{"class":142,"line":481},[140,2055,1929],{"class":164},[140,2057,268],{"class":153},[140,2059,1840],{"class":164},[140,2061,1843],{"class":383},[140,2063,387],{"class":164},[140,2065,1338],{"class":383},[140,2067,1947],{"class":164},[140,2069,2070,2072,2074,2076],{"class":142,"line":502},[140,2071,1869],{"class":153},[140,2073,2028],{"class":383},[140,2075,1960],{"class":153},[140,2077,1974],{"class":164},[140,2079,2080,2082,2085,2087],{"class":142,"line":521},[140,2081,1869],{"class":153},[140,2083,2084],{"class":383}," \"keyboard users can reach every section\"",[140,2086,1960],{"class":153},[140,2088,1974],{"class":164},[140,2090,2091],{"class":142,"line":540},[140,2092,172],{"emptyLinePlaceholder":171},[140,2094,2095],{"class":142,"line":560},[140,2096,172],{"emptyLinePlaceholder":171},[140,2098,2099,2101,2104],{"class":142,"line":580},[140,2100,618],{"class":153},[140,2102,2103],{"class":287}," test_json_is_never_truncated",[140,2105,1924],{"class":164},[140,2107,2108,2110,2112,2114,2116,2118,2120,2122,2124,2126,2128,2130,2132,2135],{"class":142,"line":600},[140,2109,1835],{"class":164},[140,2111,268],{"class":153},[140,2113,1840],{"class":164},[140,2115,1843],{"class":383},[140,2117,387],{"class":164},[140,2119,1374],{"class":383},[140,2121,1846],{"class":164},[140,2123,1849],{"class":670},[140,2125,268],{"class":153},[140,2127,1854],{"class":164},[140,2129,1857],{"class":383},[140,2131,309],{"class":164},[140,2133,2134],{"class":383},"\"40\"",[140,2136,2137],{"class":164},"})\n",[140,2139,2140,2142,2145,2147,2150,2152,2155,2157,2159,2162,2164],{"class":142,"line":605},[140,2141,1869],{"class":153},[140,2143,2144],{"class":164}," json.loads(result.output)[",[140,2146,497],{"class":157},[140,2148,2149],{"class":164},"][",[140,2151,550],{"class":383},[140,2153,2154],{"class":164},"] ",[140,2156,1034],{"class":153},[140,2158,1430],{"class":157},[140,2160,2161],{"class":164},"[",[140,2163,497],{"class":157},[140,2165,2166],{"class":164},"].branch\n",[10,2168,2169,2170,2172],{},"The parametrised fit test is the core guarantee — at 40, 60, 80 and 120 columns, no line is wider than the terminal. The other tests pin the degradation strategy: which columns drop, that truncation shows an ellipsis, that ",[14,2171,16],{}," is complete, and that JSON is untouched at any width.",[29,2174,2176],{"id":2175},"conclusion","Conclusion",[10,2178,2179,2180,2182,2183,2185,2186,17,2188,2190,2191,2193],{},"Terminal width is an input to your output. Read it with ",[14,2181,55],{}," (honouring ",[14,2184,59],{}," and falling back to 80), rank columns by importance, drop the least important on narrow screens, size essential columns to their content, cap and ellipsise the useful ones, let one flexible column absorb the rest, and give users ",[14,2187,16],{},[14,2189,20],{}," for full or reproducible output. Keep machine output complete regardless, and test at several widths through ",[14,2192,59],{},". Your tables then read cleanly in a split pane and make full use of a wide screen.",[29,2195,2197],{"id":2196},"frequently-asked-questions","Frequently asked questions",[2199,2200,2202],"h3",{"id":2201},"what-width-should-output-use-when-piped","What width should output use when piped?",[10,2204,2205,2206,2208,2209,2211],{},"The fallback — 80 columns — or whatever ",[14,2207,59],{}," says. Piped output is often read later in a pager or editor, and 80 is a safe default. For data meant for programs, provide ",[14,2210,1592],{}," or a delimited format instead of relying on table layout at all.",[2199,2213,2215],{"id":2214},"should-the-tool-react-when-the-terminal-is-resized","Should the tool react when the terminal is resized?",[10,2217,2218,2219,2222],{},"For ordinary commands, no: output is printed once. For live displays — progress bars, Rich ",[14,2220,2221],{},"Live",", Textual apps — the libraries re-read the size and re-render automatically.",[2199,2224,2226],{"id":2225},"how-do-i-handle-wide-characters-like-cjk-text-and-emoji","How do I handle wide characters like CJK text and emoji?",[10,2228,2229,2230,2233,2234,2237],{},"Rich measures display width in terminal cells rather than characters, so double-width characters are aligned correctly. ",[14,2231,2232],{},"len()"," does not; when computing widths yourself, use ",[14,2235,2236],{},"rich.cells.cell_len()"," instead.",[2199,2239,2241],{"id":2240},"is-a-vertical-layout-better-on-very-narrow-screens","Is a vertical layout better on very narrow screens?",[10,2243,2244,2245,2248],{},"Sometimes. Below about 40 columns, a \"key: value\" block per item (like ",[14,2246,2247],{},"kubectl describe",") reads better than any table. Switch layouts at a threshold rather than squeezing a table further.",[29,2250,2252],{"id":2251},"related","Related",[34,2254,2255,2261,2267,2273,2279],{},[37,2256,2257,2258],{},"Up: ",[23,2259,2260],{"href":25},"Cross-platform terminal compatibility",[37,2262,2263],{},[23,2264,2266],{"href":2265},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Frespecting-no-color-and-force-color\u002F","Respecting NO_COLOR and FORCE_COLOR",[37,2268,2269],{},[23,2270,2272],{"href":2271},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fdetecting-ci-environments-and-non-interactive-shells\u002F","Detecting CI environments and non-interactive shells",[37,2274,2275],{},[23,2276,2278],{"href":2277},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Frendering-tables-and-json-with-rich\u002F","Rendering tables and JSON with Rich",[37,2280,2281],{},[23,2282,2284],{"href":2283},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Femitting-json-output-for-scripting\u002F","Emitting JSON output for scripting",[2286,2287,2288],"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 .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}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":136,"searchDepth":150,"depth":150,"links":2290},[2291,2292,2293,2294,2295,2296,2297,2298,2304],{"id":31,"depth":150,"text":32},{"id":45,"depth":150,"text":46},{"id":77,"depth":150,"text":78},{"id":128,"depth":150,"text":129},{"id":1600,"depth":150,"text":1601},{"id":1651,"depth":150,"text":1652},{"id":2175,"depth":150,"text":2176},{"id":2196,"depth":150,"text":2197,"children":2299},[2300,2301,2302,2303],{"id":2201,"depth":168,"text":2202},{"id":2214,"depth":168,"text":2215},{"id":2225,"depth":168,"text":2226},{"id":2240,"depth":168,"text":2241},{"id":2251,"depth":150,"text":2252},"2026-09-18","Fit tables and text to any terminal from a Python CLI: detect width, prioritise columns, truncate with ellipses, offer --wide and --width, and keep JSON untouched.","intermediate",false,"md",{},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fadapting-output-to-terminal-width",{"title":5,"description":2306},"advanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fadapting-output-to-terminal-width\u002Findex",[2315,2316,2317,2318],"terminal","rich","tables","layout","h3Y6RTfwLVI7G1HsB4kttjrpUdPgcJG5SVz6F1h29gs",[2321,2324,2327,2330,2333,2336,2339,2342,2345,2348,2351,2354,2357,2360,2363,2366,2367,2370,2373,2376,2379,2382,2385,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,2547,2550,2553,2556,2559,2562,2565,2568,2571,2574,2577,2580,2583,2586,2589,2592,2595,2598,2601,2604,2607,2610,2613,2616,2619,2622,2625,2628,2631,2634,2637,2640,2643,2646,2649,2652,2655,2658,2661,2664,2667,2670,2673,2676,2679,2682,2685,2688,2691,2694,2697,2700,2703,2706,2709,2712,2715,2718,2721,2724,2727,2730,2733,2736,2739,2742,2745,2748,2751,2754,2757,2760,2763,2766,2769,2772,2775,2778,2781,2784,2787,2790,2793,2796,2799,2802,2805,2808,2811,2814,2817,2820,2823,2826,2829,2832,2835,2838,2841,2844,2847,2850,2853,2856,2859,2862,2865],{"path":2322,"title":2323},"\u002Fabout","About Python CLI Toolcraft",{"path":2325,"title":2326},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies","Advanced Argument Validation Strategies",{"path":2328,"title":2329},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fparsing-nested-json-arguments-in-python-clis","Parsing Nested JSON Args in Python CLIs",{"path":2331,"title":2332},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-dependent-and-conflicting-options","Validating Dependent and Conflicting CLI Options",{"path":2334,"title":2335},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-file-and-directory-paths-in-clis","Validating File and Directory Paths in CLIs",{"path":2337,"title":2338},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fwriting-custom-click-parameter-types","Writing Custom Click Parameter Types",{"path":2340,"title":2341},"\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":2343,"title":2344},"\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":2346,"title":2347},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual","Building Terminal UIs with Textual for Python CLIs",{"path":2349,"title":2350},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual\u002Ftesting-textual-apps-with-pilot","Testing Textual Apps with Pilot",{"path":2352,"title":2353},"\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":2355,"title":2356},"\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":2358,"title":2359},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation","CLI Help Output and Documentation",{"path":2361,"title":2362},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fversioning-and-deprecating-cli-flags","Versioning and Deprecating CLI Flags",{"path":2364,"title":2365},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fwriting-help-text-users-actually-read","Writing Help Text Users Actually Read",{"path":2311,"title":5},{"path":2368,"title":2369},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fdetecting-ci-environments-and-non-interactive-shells","Detecting CI Environments and Non-Interactive Shells",{"path":2371,"title":2372},"\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":2374,"title":2375},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility","Cross-Platform Terminal Compatibility for Python CLIs",{"path":2377,"title":2378},"\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":2380,"title":2381},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fchoosing-exit-codes-for-cli-tools","Choosing Exit Codes for CLI Tools",{"path":2383,"title":2384},"\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":2386,"title":2387},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Ffriendly-error-messages-and-tracebacks","Friendly Error Messages and Tracebacks",{"path":2389,"title":2390},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fhandling-keyboard-interrupt-cleanly","Handling Keyboard Interrupt Cleanly",{"path":2392,"title":2393},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes","Error Handling and Exit Codes for CLIs",{"path":2395,"title":2396},"\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":2398,"title":2399},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Fconfig-precedence-flags-env-files-defaults","Config Precedence: Flags, Env, Files, Defaults",{"path":2401,"title":2402},"\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":2404,"title":2405},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars","Handling Config Files and Env Vars in CLIs",{"path":2407,"title":2408},"\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":2410,"title":2411},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Freading-toml-config-with-tomllib","Reading TOML Config with tomllib in Python CLIs",{"path":2413,"title":2414},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Ftyped-settings-with-pydantic-settings","Typed Settings with pydantic-settings in Python CLIs",{"path":2416,"title":2417},"\u002Fadvanced-input-parsing-user-experience","Advanced Input Parsing for Python CLIs",{"path":2419,"title":2420},"\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":2422,"title":2423},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Fbuilding-interactive-prompts-and-menus","Building Interactive Prompts and Menus in Python CLIs",{"path":2425,"title":2426},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich","Interactive Terminal UI with Rich",{"path":2428,"title":2429},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Flive-dashboards-with-rich-live","Live Dashboards with Rich Live in Python CLIs",{"path":2431,"title":2432},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Frendering-tables-and-json-with-rich","Rendering Tables and JSON with Rich",{"path":2434,"title":2435},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Ftheming-rich-output-consistently","Theming Rich Output Consistently in Python CLIs",{"path":2437,"title":2438},"\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":2440,"title":2441},"\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":2443,"title":2444},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis","Shell Completion for Python CLIs",{"path":2446,"title":2447},"\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":2449,"title":2450},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis\u002Ftesting-shell-completion-in-python-clis","Testing Shell Completion in Python CLIs",{"path":2452,"title":2453},"\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":2455,"title":2456},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Fadding-verbose-and-quiet-logging-flags","Adding Verbose and Quiet Logging Flags",{"path":2458,"title":2459},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps","Structured Logging for CLI Apps",{"path":2461,"title":2462},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Fstructured-json-logging-in-python-clis","Structured JSON Logging in Python CLIs",{"path":2464,"title":2465},"\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":2467,"title":2468},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fdetecting-tty-and-adapting-output","Detecting a TTY and Adapting Output",{"path":2470,"title":2471},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Femitting-json-output-for-scripting","Emitting JSON Output for Scripting",{"path":2473,"title":2474},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fhandling-broken-pipe-and-sigpipe","Handling Broken Pipe and SIGPIPE",{"path":2476,"title":2477},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes","Working with stdin, stdout and Pipes",{"path":2479,"title":2480},"\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":2482,"title":2483},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Freading-piped-input-in-python-clis","Reading Piped Input in Python CLIs",{"path":2485,"title":2486},"\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":2488,"title":2489},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fdownloading-files-with-progress-in-python","Downloading Files with Progress in Python CLIs",{"path":2491,"title":2492},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis","Calling HTTP APIs from Python CLIs",{"path":2494,"title":2495},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Foauth-device-flow-login-for-clis","OAuth Device Flow Login for Python CLIs",{"path":2497,"title":2498},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fpaginating-api-results-in-a-cli","Paginating API Results in a Python CLI",{"path":2500,"title":2501},"\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":2503,"title":2504},"\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":2506,"title":2507},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis","Concurrency and Async in Python CLIs",{"path":2509,"title":2510},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Fmultiprocessing-for-cpu-bound-cli-tasks","Multiprocessing for CPU-Bound CLI Tasks",{"path":2512,"title":2513},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Fparallelising-cli-work-with-thread-pools","Parallelising CLI Work with Thread Pools",{"path":2515,"title":2516},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Frate-limiting-concurrent-requests-in-clis","Rate-Limiting Concurrent Requests in Python CLIs",{"path":2518,"title":2519},"\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":2521,"title":2522},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fcross-platform-paths-with-pathlib","Cross-Platform Paths with pathlib in CLIs",{"path":2524,"title":2525},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Ffile-locking-for-concurrent-cli-runs","File Locking for Concurrent CLI Runs in Python",{"path":2527,"title":2528},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes","Filesystem Paths and Atomic Writes for CLIs",{"path":2530,"title":2531},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fsafe-temporary-files-and-directories","Safe Temporary Files and Directories in CLIs",{"path":2533,"title":2534},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fstoring-app-data-with-platformdirs","Storing CLI App Data with platformdirs",{"path":2536,"title":2537},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fwriting-files-atomically-in-python-clis","Writing Files Atomically in Python CLIs",{"path":2539,"title":2540},"\u002Fcli-runtime-systems-integration","CLI Runtime & Systems Integration for Python",{"path":2542,"title":2543},"\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":2545,"title":2546},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Fhandling-sigterm-and-graceful-shutdown","Handling SIGTERM and Graceful Shutdown in CLIs",{"path":2548,"title":2549},"\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":2551,"title":2552},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis","Long-Running and Watch-Mode Python CLIs",{"path":2554,"title":2555},"\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":2557,"title":2558},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Favoiding-shell-injection-in-python-clis","Avoiding Shell Injection in Python CLIs",{"path":2560,"title":2561},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fcalling-external-commands-safely-with-subprocess","Calling External Commands Safely with subprocess",{"path":2563,"title":2564},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fhandling-subprocess-timeouts-and-exit-codes","Handling Subprocess Timeouts and Exit Codes",{"path":2566,"title":2567},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis","Running Subprocesses from Python CLIs",{"path":2569,"title":2570},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fstreaming-subprocess-output-in-real-time","Streaming Subprocess Output in Real Time",{"path":2572,"title":2573},"\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":2575,"title":2576},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis","Secrets and Credentials in Python CLIs",{"path":2578,"title":2579},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fprompting-for-passwords-securely","Prompting for Passwords Securely in Python CLIs",{"path":2581,"title":2582},"\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":2584,"title":2585},"\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":2587,"title":2588},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fstoring-tokens-with-keyring","Storing CLI Tokens Securely with keyring",{"path":2590,"title":2591},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fsupporting-multiple-profiles-and-accounts","Supporting Multiple Profiles and Accounts in CLIs",{"path":2593,"title":2594},"\u002F","Python CLI Toolcraft",{"path":2596,"title":2597},"\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":2599,"title":2600},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading","CLI Startup Performance and Lazy Loading",{"path":2602,"title":2603},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Flazy-loading-subcommands-for-faster-startup","Lazy Loading Subcommands for Faster Startup",{"path":2605,"title":2606},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Fprofiling-python-cli-startup-time","Profiling Python CLI Startup Time",{"path":2608,"title":2609},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Freducing-cli-dependency-weight","Reducing CLI Dependency Weight",{"path":2611,"title":2612},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fargparse-subparsers-for-subcommands","argparse Subparsers for Subcommands",{"path":2614,"title":2615},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fargparse-vs-click-vs-typer-comparison","argparse vs Click vs Typer Compared",{"path":2617,"title":2618},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse","Command-Line Parsing with argparse",{"path":2620,"title":2621},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fmigrating-from-argparse-to-typer","Migrating from argparse to Typer",{"path":2623,"title":2624},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fmutually-exclusive-options-in-argparse","Mutually Exclusive Options in argparse",{"path":2626,"title":2627},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fwriting-custom-argparse-actions","Writing Custom argparse Actions in Python",{"path":2629,"title":2630},"\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":2632,"title":2633},"\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":2635,"title":2636},"\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":2638,"title":2639},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions","Designing CLI Interfaces and Conventions in Python",{"path":2641,"title":2642},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions\u002Fnaming-commands-and-flags-consistently","Naming Commands and Flags Consistently in Python CLIs",{"path":2644,"title":2645},"\u002Fmodern-python-cli-frameworks-architecture","Python CLI Frameworks and Architecture",{"path":2647,"title":2648},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fdiscovering-plugins-with-entry-points","Discovering Plugins with Entry Points in Python CLIs",{"path":2650,"title":2651},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fhook-based-plugins-with-pluggy","Hook-Based Plugins for Python CLIs with pluggy",{"path":2653,"title":2654},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis","Plugin Architectures for Extensible CLIs",{"path":2656,"title":2657},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fversioning-a-plugin-api","Versioning a Plugin API for a Python CLI",{"path":2659,"title":2660},"\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":2662,"title":2663},"\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":2665,"title":2666},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fdependency-injection-patterns-for-cli-commands","Dependency Injection Patterns for CLI Commands",{"path":2668,"title":2669},"\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":2671,"title":2672},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis","Structuring Multi-Command Python CLIs",{"path":2674,"title":2675},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fsharing-common-options-across-commands","Sharing Common Options Across Python CLI Commands",{"path":2677,"title":2678},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fsharing-state-with-click-context-objects","Sharing State with Click Context Objects",{"path":2680,"title":2681},"\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":2683,"title":2684},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications","Testing Python CLI Applications",{"path":2686,"title":2687},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fmeasuring-cli-test-coverage","Measuring CLI Test Coverage",{"path":2689,"title":2690},"\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":2692,"title":2693},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fproperty-based-testing-cli-arguments-with-hypothesis","Property-Based Testing CLI Arguments with Hypothesis",{"path":2695,"title":2696},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fsnapshot-testing-cli-output","Snapshot Testing CLI Output",{"path":2698,"title":2699},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Ftesting-click-commands-with-clirunner","Testing Click Commands with CliRunner",{"path":2701,"title":2702},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Ftesting-interactive-prompts-and-stdin","Testing Interactive Prompts and stdin",{"path":2704,"title":2705},"\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":2707,"title":2708},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fbuilding-dynamic-commands-in-click","Building Dynamic Commands in Click",{"path":2710,"title":2711},"\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":2713,"title":2714},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each","Typer vs Click: When to Use Each",{"path":2716,"title":2717},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Ftyper-callback-functions-explained","Typer callback functions explained",{"path":2719,"title":2720},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fusing-annotated-options-in-typer","Using Annotated Options in Typer",{"path":2722,"title":2723},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Fautomating-releases-from-git-tags","Automating Python CLI Releases from Git Tags",{"path":2725,"title":2726},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Fcaching-uv-dependencies-in-ci","Caching uv Dependencies in CI for Python CLIs",{"path":2728,"title":2729},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis","CI\u002FCD Pipelines for Python CLIs",{"path":2731,"title":2732},"\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":2734,"title":2735},"\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":2737,"title":2738},"\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":2740,"title":2741},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fbuilding-a-cookiecutter-template-for-typer-clis","Building a Cookiecutter Template for Typer CLIs",{"path":2743,"title":2744},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fcopier-vs-cookiecutter-for-cli-templates","Copier vs Cookiecutter for CLI Templates",{"path":2746,"title":2747},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter","CLI Project Scaffolding with Cookiecutter",{"path":2749,"title":2750},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fpost-generation-hooks-in-cli-templates","Post-Generation Hooks in Python CLI Templates",{"path":2752,"title":2753},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fbuilding-cross-platform-release-binaries-in-ci","Building Cross-Platform Release Binaries in CI",{"path":2755,"title":2756},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fbundling-a-python-cli-with-pyinstaller","Bundling a Python CLI with PyInstaller",{"path":2758,"title":2759},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fhomebrew-and-scoop-packaging-for-python-clis","Homebrew and Scoop Packaging for Python CLIs",{"path":2761,"title":2762},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries","Distributing CLIs as Standalone Binaries",{"path":2764,"title":2765},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fnuitka-vs-pyinstaller-for-python-clis","Nuitka vs PyInstaller for Python CLI Binaries",{"path":2767,"title":2768},"\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":2770,"title":2771},"\u002Fproject-setup-dependency-management","Project Setup & Dependency Management",{"path":2773,"title":2774},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code\u002Fconfiguring-ruff-for-a-cli-project","Configuring Ruff for a Python CLI Project",{"path":2776,"title":2777},"\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":2779,"title":2780},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code","Linting and Type-Checking Python CLI Code",{"path":2782,"title":2783},"\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":2785,"title":2786},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fautomating-changelogs-with-conventional-commits","Automating Changelogs with Conventional Commits",{"path":2788,"title":2789},"\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":2791,"title":2792},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fexposing-version-info-and-build-metadata","Exposing Version Info and Build Metadata",{"path":2794,"title":2795},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs","Managing CLI Versioning & Changelogs",{"path":2797,"title":2798},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fsemantic-versioning-policy-for-cli-tools","A Semantic Versioning Policy for CLI Tools",{"path":2800,"title":2801},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fbuilding-wheels-and-sdists-for-python-clis","Building Wheels and sdists for Python CLIs",{"path":2803,"title":2804},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fbundling-data-files-with-importlib-resources","Bundling Data Files with importlib.resources in CLIs",{"path":2806,"title":2807},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution","Packaging Python CLIs for Distribution",{"path":2809,"title":2810},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Finstalling-and-distributing-clis-with-pipx","Installing and Distributing CLIs with pipx",{"path":2812,"title":2813},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fpublishing-a-python-cli-to-pypi","Publishing a Python CLI to PyPI",{"path":2815,"title":2816},"\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":2818,"title":2819},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development","Poetry Workflows for CLI Development",{"path":2821,"title":2822},"\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":2824,"title":2825},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fpoetry-dependency-groups-for-cli-tooling","Poetry Dependency Groups for CLI Tooling",{"path":2827,"title":2828},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fpoetry-entry-points-and-scripts-for-clis","Poetry Entry Points and Scripts for CLIs",{"path":2830,"title":2831},"\u002Fproject-setup-dependency-management\u002Fpre-commit-hooks-for-cli-projects","Pre-commit Hooks for CLI Projects",{"path":2833,"title":2834},"\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":2836,"title":2837},"\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":2839,"title":2840},"\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":2842,"title":2843},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management","uv for Python CLI Dependency Management",{"path":2845,"title":2846},"\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":2848,"title":2849},"\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":2851,"title":2852},"\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":2854,"title":2855},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management\u002Fuv-workspaces-for-multi-package-clis","uv Workspaces for Multi-Package Python CLIs",{"path":2857,"title":2858},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices","Python CLI Env Isolation Best Practices",{"path":2860,"title":2861},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fmanaging-virtual-environments-for-cross-platform-clis","Managing Python CLI Virtual Environments",{"path":2863,"title":2864},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fpinning-the-python-version-for-a-cli","Pinning the Python Version for a CLI",{"path":2866,"title":2867},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fsupporting-multiple-python-versions-with-nox","Supporting Multiple Python Versions with nox",1789736905043]