[{"data":1,"prerenderedAt":3264},["ShallowReactive",2],{"page-\u002Fadvanced-input-parsing-user-experience\u002Foutput-formats-for-data-clis\u002F":3,"content-directory":2419},{"id":4,"title":5,"body":6,"date":2405,"description":2406,"difficulty":2407,"draft":2408,"extension":2409,"meta":2410,"navigation":268,"path":2411,"seo":2412,"stem":2413,"tags":2414,"updated":2405,"__hash__":2418},"content\u002Fadvanced-input-parsing-user-experience\u002Foutput-formats-for-data-clis\u002Findex.md","Output Formats for Data-Heavy Python CLIs",{"type":7,"value":8,"toc":2383},"minimark",[9,26,49,53,58,131,135,138,141,163,166,169,173,176,179,220,227,996,999,1250,1273,1277,1280,1283,1297,1318,1333,1344,1348,1351,1354,1413,1420,1424,1441,1635,1647,1663,1667,1681,1684,1712,1716,1726,1809,1834,1838,1849,2128,2136,2140,2210,2214,2243,2247,2259,2273,2277,2284,2288,2303,2307,2315,2319,2329,2333,2379],[10,11,12,13,17,18,21,22,25],"p",{},"Sooner or later every CLI that lists things gets the same three feature requests. Someone wants to paste the output into a spreadsheet, so they ask for CSV. Someone wants to feed it into another tool, so they ask for JSON. Someone wants only two of the eleven columns in a shell loop, so they ask for \"a way to pick fields\". Each request is reasonable on its own, and each one bolted on separately — a ",[14,15,16],"code",{},"--csv"," flag here, a ",[14,19,20],{},"--json"," flag there, a ",[14,23,24],{},"--fields"," option that only works with one of them — produces a command surface nobody can predict. The fix is to treat output format as one concern with one design: a single format option, a rendering layer that every command shares, and a small set of rules about what each format guarantees.",[10,27,28,29,34,35,39,40,44,45,48],{},"This topic builds that design. It sits in the ",[30,31,33],"a",{"href":32},"\u002Fadvanced-input-parsing-user-experience\u002F","Advanced Input Parsing & User Experience"," section next to ",[30,36,38],{"href":37},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002F","working with stdin, stdout and pipes",", which covers the stream mechanics, and ",[30,41,43],{"href":42},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002F","interactive terminal UI with Rich",", which covers the human-facing table. Here the question is narrower and more practical: when the same records must reach a person, a spreadsheet, a ",[14,46,47],{},"jq"," pipeline and a shell loop, how do you serve all four without four code paths?",[50,51],"inline-diagram",{"name":52},"ofmt-topic-map",[54,55,57],"h2",{"id":56},"tldr","TL;DR",[59,60,61,93,99,105,111,125],"ul",{},[62,63,64,68,69,72,73,76,77,76,80,76,83,76,86,76,89,92],"li",{},[65,66,67],"strong",{},"One option, many formats."," Expose ",[14,70,71],{},"--output\u002F-o"," with a fixed set of choices (",[14,74,75],{},"table",", ",[14,78,79],{},"json",[14,81,82],{},"jsonl",[14,84,85],{},"csv",[14,87,88],{},"tsv",[14,90,91],{},"template",") on every listing command, never a separate boolean flag per format.",[62,94,95,98],{},[65,96,97],{},"Commands return records; renderers print them."," A command produces a list of plain dictionaries and a column list. A shared renderer table turns that into text. No command ever formats its own output.",[62,100,101,104],{},[65,102,103],{},"Pick the default by audience."," A table on a terminal; a stable machine format when stdout is a pipe. Let an environment variable override the default for people who always want JSON.",[62,106,107,110],{},[65,108,109],{},"Treat machine formats as an API."," Field names, types and ordering in JSON and CSV are a contract that scripts depend on. Version them like any other interface.",[62,112,113,116,117,120,121,124],{},[65,114,115],{},"Selection and templates sit on top."," ",[14,118,119],{},"--fields name,status"," trims columns for every format; ",[14,122,123],{},"--format '{name}\\t{status}'"," covers the one-off shell loop without inventing a mini language.",[62,126,127,130],{},[65,128,129],{},"Test every format with snapshots"," of the exact bytes, because the bugs live in quoting, escaping and line endings.",[54,132,134],{"id":133},"who-reads-your-output","Who reads your output",[10,136,137],{},"Before deciding which formats to offer, it helps to name the readers. A command's output has at least four distinct consumers, and they want contradictory things.",[50,139],{"name":140},"ofmt-readers",[10,142,143,144,147,148,151,152,154,155,158,159,162],{},"A ",[65,145,146],{},"person at a terminal"," wants alignment, truncation to fit the window, colour for status, and human units (\"3 minutes ago\", \"1.2 GB\"). A ",[65,149,150],{},"program"," — ",[14,153,47],{},", a Python script, a CI step — wants exact values: ISO timestamps, byte counts, stable keys, nothing truncated, no colour codes. A ",[65,156,157],{},"spreadsheet user"," wants CSV with a header row and quoting that Excel and LibreOffice both understand. A ",[65,160,161],{},"shell loop"," wants one record per line with fields split by a character that cannot appear inside a field — usually a tab.",[10,164,165],{},"The mistake is to optimise one format for two readers. A table \"that is also easy to parse\" ends up with fixed-width columns that break on long names. JSON \"that is also readable\" grows pretty-printed whitespace and human units that scripts then have to un-format. Give each reader its own format and let each format be uncompromising about its job.",[10,167,168],{},"That split also decides where data gets converted. Human formatting — relative times, rounding, truncation, colour — happens only inside the table renderer. Every other renderer receives the raw values. If a command pre-formats a timestamp as \"3 minutes ago\" before handing records to the renderer, the JSON output is ruined for every script that consumes it.",[54,170,172],{"id":171},"the-shape-of-the-solution","The shape of the solution",[10,174,175],{},"The design that keeps this manageable has three layers, and the boundaries matter more than any individual piece of code.",[50,177],{"name":178},"ofmt-render-pipeline",[180,181,182,193,210],"ol",{},[62,183,184,187,188,192],{},[65,185,186],{},"The command"," does the work and returns ",[189,190,191],"em",{},"records",": a list of dictionaries with raw, JSON-serialisable values, plus the list of default columns in display order. It knows nothing about formats.",[62,194,195,198,199,201,202,205,206,209],{},[65,196,197],{},"The selection step"," applies the cross-format options: ",[14,200,24],{}," to choose and order columns, and optionally ",[14,203,204],{},"--sort"," and ",[14,207,208],{},"--limit",". Because it runs before rendering, every format gets the same rows and columns.",[62,211,212,215,216,219],{},[65,213,214],{},"The renderer"," for the chosen format turns rows and columns into text, and the command layer writes that text to stdout — or to a file when ",[14,217,218],{},"--output-file"," is given.",[10,221,222,223,226],{},"In code the renderer layer is a dictionary from an ",[14,224,225],{},"Enum"," to a function, which keeps the set of formats closed and lets the framework validate the option:",[228,229,234],"pre",{"className":230,"code":231,"language":232,"meta":233,"style":233},"language-python shiki shiki-themes github-light github-dark","# src\u002Fmytool\u002Foutput.py\nfrom __future__ import annotations\n\nimport csv\nimport io\nimport json\nimport sys\nfrom collections.abc import Callable, Sequence\nfrom enum import Enum\nfrom typing import Any\n\nRow = dict[str, Any]\n\n\nclass Format(str, Enum):\n    table = \"table\"\n    json = \"json\"\n    jsonl = \"jsonl\"\n    csv = \"csv\"\n\n\ndef render_table(rows: Sequence[Row], columns: Sequence[str]) -> str:\n    from rich.console import Console      # imported lazily: only tables need Rich\n    from rich.table import Table\n\n    table = Table(*columns, box=None, pad_edge=False)\n    for row in rows:\n        table.add_row(*(str(row.get(c, \"\")) for c in columns))\n    buf = io.StringIO()\n    Console(file=buf, width=100).print(table)\n    return buf.getvalue()\n\n\ndef render_json(rows: Sequence[Row], columns: Sequence[str]) -> str:\n    return json.dumps([{c: r.get(c) for c in columns} for r in rows], indent=2) + \"\\n\"\n\n\ndef render_jsonl(rows: Sequence[Row], columns: Sequence[str]) -> str:\n    return \"\".join(json.dumps({c: r.get(c) for c in columns}) + \"\\n\" for r in rows)\n\n\ndef render_csv(rows: Sequence[Row], columns: Sequence[str]) -> str:\n    buf = io.StringIO(newline=\"\")\n    writer = csv.DictWriter(buf, fieldnames=columns, extrasaction=\"ignore\", lineterminator=\"\\n\")\n    writer.writeheader()\n    writer.writerows(rows)\n    return buf.getvalue()\n\n\nRENDERERS: dict[Format, Callable[[Sequence[Row], Sequence[str]], str]] = {\n    Format.table: render_table,\n    Format.json: render_json,\n    Format.jsonl: render_jsonl,\n    Format.csv: render_csv,\n}\n\n\ndef default_format() -> Format:\n    return Format.table if sys.stdout.isatty() else Format.jsonl\n","python","",[14,235,236,245,263,270,279,287,295,303,316,329,342,347,365,370,375,397,409,420,431,442,447,452,474,491,504,509,547,562,594,605,630,639,644,649,667,717,722,727,745,784,789,794,812,831,872,878,884,891,896,901,925,931,937,943,949,955,960,965,976],{"__ignoreMap":233},[237,238,241],"span",{"class":239,"line":240},"line",1,[237,242,244],{"class":243},"sJ8bj","# src\u002Fmytool\u002Foutput.py\n",[237,246,248,252,256,259],{"class":239,"line":247},2,[237,249,251],{"class":250},"szBVR","from",[237,253,255],{"class":254},"sj4cs"," __future__",[237,257,258],{"class":250}," import",[237,260,262],{"class":261},"sVt8B"," annotations\n",[237,264,266],{"class":239,"line":265},3,[237,267,269],{"emptyLinePlaceholder":268},true,"\n",[237,271,273,276],{"class":239,"line":272},4,[237,274,275],{"class":250},"import",[237,277,278],{"class":261}," csv\n",[237,280,282,284],{"class":239,"line":281},5,[237,283,275],{"class":250},[237,285,286],{"class":261}," io\n",[237,288,290,292],{"class":239,"line":289},6,[237,291,275],{"class":250},[237,293,294],{"class":261}," json\n",[237,296,298,300],{"class":239,"line":297},7,[237,299,275],{"class":250},[237,301,302],{"class":261}," sys\n",[237,304,306,308,311,313],{"class":239,"line":305},8,[237,307,251],{"class":250},[237,309,310],{"class":261}," collections.abc ",[237,312,275],{"class":250},[237,314,315],{"class":261}," Callable, Sequence\n",[237,317,319,321,324,326],{"class":239,"line":318},9,[237,320,251],{"class":250},[237,322,323],{"class":261}," enum ",[237,325,275],{"class":250},[237,327,328],{"class":261}," Enum\n",[237,330,332,334,337,339],{"class":239,"line":331},10,[237,333,251],{"class":250},[237,335,336],{"class":261}," typing ",[237,338,275],{"class":250},[237,340,341],{"class":261}," Any\n",[237,343,345],{"class":239,"line":344},11,[237,346,269],{"emptyLinePlaceholder":268},[237,348,350,353,356,359,362],{"class":239,"line":349},12,[237,351,352],{"class":261},"Row ",[237,354,355],{"class":250},"=",[237,357,358],{"class":261}," dict[",[237,360,361],{"class":254},"str",[237,363,364],{"class":261},", Any]\n",[237,366,368],{"class":239,"line":367},13,[237,369,269],{"emptyLinePlaceholder":268},[237,371,373],{"class":239,"line":372},14,[237,374,269],{"emptyLinePlaceholder":268},[237,376,378,381,385,388,390,392,394],{"class":239,"line":377},15,[237,379,380],{"class":250},"class",[237,382,384],{"class":383},"sScJk"," Format",[237,386,387],{"class":261},"(",[237,389,361],{"class":254},[237,391,76],{"class":261},[237,393,225],{"class":383},[237,395,396],{"class":261},"):\n",[237,398,400,403,405],{"class":239,"line":399},16,[237,401,402],{"class":261},"    table ",[237,404,355],{"class":250},[237,406,408],{"class":407},"sZZnC"," \"table\"\n",[237,410,412,415,417],{"class":239,"line":411},17,[237,413,414],{"class":261},"    json ",[237,416,355],{"class":250},[237,418,419],{"class":407}," \"json\"\n",[237,421,423,426,428],{"class":239,"line":422},18,[237,424,425],{"class":261},"    jsonl ",[237,427,355],{"class":250},[237,429,430],{"class":407}," \"jsonl\"\n",[237,432,434,437,439],{"class":239,"line":433},19,[237,435,436],{"class":261},"    csv ",[237,438,355],{"class":250},[237,440,441],{"class":407}," \"csv\"\n",[237,443,445],{"class":239,"line":444},20,[237,446,269],{"emptyLinePlaceholder":268},[237,448,450],{"class":239,"line":449},21,[237,451,269],{"emptyLinePlaceholder":268},[237,453,455,458,461,464,466,469,471],{"class":239,"line":454},22,[237,456,457],{"class":250},"def",[237,459,460],{"class":383}," render_table",[237,462,463],{"class":261},"(rows: Sequence[Row], columns: Sequence[",[237,465,361],{"class":254},[237,467,468],{"class":261},"]) -> ",[237,470,361],{"class":254},[237,472,473],{"class":261},":\n",[237,475,477,480,483,485,488],{"class":239,"line":476},23,[237,478,479],{"class":250},"    from",[237,481,482],{"class":261}," rich.console ",[237,484,275],{"class":250},[237,486,487],{"class":261}," Console      ",[237,489,490],{"class":243},"# imported lazily: only tables need Rich\n",[237,492,494,496,499,501],{"class":239,"line":493},24,[237,495,479],{"class":250},[237,497,498],{"class":261}," rich.table ",[237,500,275],{"class":250},[237,502,503],{"class":261}," Table\n",[237,505,507],{"class":239,"line":506},25,[237,508,269],{"emptyLinePlaceholder":268},[237,510,512,514,516,519,522,525,529,531,534,536,539,541,544],{"class":239,"line":511},26,[237,513,402],{"class":261},[237,515,355],{"class":250},[237,517,518],{"class":261}," Table(",[237,520,521],{"class":250},"*",[237,523,524],{"class":261},"columns, ",[237,526,528],{"class":527},"s4XuR","box",[237,530,355],{"class":250},[237,532,533],{"class":254},"None",[237,535,76],{"class":261},[237,537,538],{"class":527},"pad_edge",[237,540,355],{"class":250},[237,542,543],{"class":254},"False",[237,545,546],{"class":261},")\n",[237,548,550,553,556,559],{"class":239,"line":549},27,[237,551,552],{"class":250},"    for",[237,554,555],{"class":261}," row ",[237,557,558],{"class":250},"in",[237,560,561],{"class":261}," rows:\n",[237,563,565,568,570,572,574,577,580,583,586,589,591],{"class":239,"line":564},28,[237,566,567],{"class":261},"        table.add_row(",[237,569,521],{"class":250},[237,571,387],{"class":261},[237,573,361],{"class":254},[237,575,576],{"class":261},"(row.get(c, ",[237,578,579],{"class":407},"\"\"",[237,581,582],{"class":261},")) ",[237,584,585],{"class":250},"for",[237,587,588],{"class":261}," c ",[237,590,558],{"class":250},[237,592,593],{"class":261}," columns))\n",[237,595,597,600,602],{"class":239,"line":596},29,[237,598,599],{"class":261},"    buf ",[237,601,355],{"class":250},[237,603,604],{"class":261}," io.StringIO()\n",[237,606,608,611,614,616,619,622,624,627],{"class":239,"line":607},30,[237,609,610],{"class":261},"    Console(",[237,612,613],{"class":527},"file",[237,615,355],{"class":250},[237,617,618],{"class":261},"buf, ",[237,620,621],{"class":527},"width",[237,623,355],{"class":250},[237,625,626],{"class":254},"100",[237,628,629],{"class":261},").print(table)\n",[237,631,633,636],{"class":239,"line":632},31,[237,634,635],{"class":250},"    return",[237,637,638],{"class":261}," buf.getvalue()\n",[237,640,642],{"class":239,"line":641},32,[237,643,269],{"emptyLinePlaceholder":268},[237,645,647],{"class":239,"line":646},33,[237,648,269],{"emptyLinePlaceholder":268},[237,650,652,654,657,659,661,663,665],{"class":239,"line":651},34,[237,653,457],{"class":250},[237,655,656],{"class":383}," render_json",[237,658,463],{"class":261},[237,660,361],{"class":254},[237,662,468],{"class":261},[237,664,361],{"class":254},[237,666,473],{"class":261},[237,668,670,672,675,677,679,681,684,686,689,691,694,697,699,702,705,708,711,714],{"class":239,"line":669},35,[237,671,635],{"class":250},[237,673,674],{"class":261}," json.dumps([{c: r.get(c) ",[237,676,585],{"class":250},[237,678,588],{"class":261},[237,680,558],{"class":250},[237,682,683],{"class":261}," columns} ",[237,685,585],{"class":250},[237,687,688],{"class":261}," r ",[237,690,558],{"class":250},[237,692,693],{"class":261}," rows], ",[237,695,696],{"class":527},"indent",[237,698,355],{"class":250},[237,700,701],{"class":254},"2",[237,703,704],{"class":261},") ",[237,706,707],{"class":250},"+",[237,709,710],{"class":407}," \"",[237,712,713],{"class":254},"\\n",[237,715,716],{"class":407},"\"\n",[237,718,720],{"class":239,"line":719},36,[237,721,269],{"emptyLinePlaceholder":268},[237,723,725],{"class":239,"line":724},37,[237,726,269],{"emptyLinePlaceholder":268},[237,728,730,732,735,737,739,741,743],{"class":239,"line":729},38,[237,731,457],{"class":250},[237,733,734],{"class":383}," render_jsonl",[237,736,463],{"class":261},[237,738,361],{"class":254},[237,740,468],{"class":261},[237,742,361],{"class":254},[237,744,473],{"class":261},[237,746,748,750,753,756,758,760,762,765,767,769,771,774,777,779,781],{"class":239,"line":747},39,[237,749,635],{"class":250},[237,751,752],{"class":407}," \"\"",[237,754,755],{"class":261},".join(json.dumps({c: r.get(c) ",[237,757,585],{"class":250},[237,759,588],{"class":261},[237,761,558],{"class":250},[237,763,764],{"class":261}," columns}) ",[237,766,707],{"class":250},[237,768,710],{"class":407},[237,770,713],{"class":254},[237,772,773],{"class":407},"\"",[237,775,776],{"class":250}," for",[237,778,688],{"class":261},[237,780,558],{"class":250},[237,782,783],{"class":261}," rows)\n",[237,785,787],{"class":239,"line":786},40,[237,788,269],{"emptyLinePlaceholder":268},[237,790,792],{"class":239,"line":791},41,[237,793,269],{"emptyLinePlaceholder":268},[237,795,797,799,802,804,806,808,810],{"class":239,"line":796},42,[237,798,457],{"class":250},[237,800,801],{"class":383}," render_csv",[237,803,463],{"class":261},[237,805,361],{"class":254},[237,807,468],{"class":261},[237,809,361],{"class":254},[237,811,473],{"class":261},[237,813,815,817,819,822,825,827,829],{"class":239,"line":814},43,[237,816,599],{"class":261},[237,818,355],{"class":250},[237,820,821],{"class":261}," io.StringIO(",[237,823,824],{"class":527},"newline",[237,826,355],{"class":250},[237,828,579],{"class":407},[237,830,546],{"class":261},[237,832,834,837,839,842,845,847,849,852,854,857,859,862,864,866,868,870],{"class":239,"line":833},44,[237,835,836],{"class":261},"    writer ",[237,838,355],{"class":250},[237,840,841],{"class":261}," csv.DictWriter(buf, ",[237,843,844],{"class":527},"fieldnames",[237,846,355],{"class":250},[237,848,524],{"class":261},[237,850,851],{"class":527},"extrasaction",[237,853,355],{"class":250},[237,855,856],{"class":407},"\"ignore\"",[237,858,76],{"class":261},[237,860,861],{"class":527},"lineterminator",[237,863,355],{"class":250},[237,865,773],{"class":407},[237,867,713],{"class":254},[237,869,773],{"class":407},[237,871,546],{"class":261},[237,873,875],{"class":239,"line":874},45,[237,876,877],{"class":261},"    writer.writeheader()\n",[237,879,881],{"class":239,"line":880},46,[237,882,883],{"class":261},"    writer.writerows(rows)\n",[237,885,887,889],{"class":239,"line":886},47,[237,888,635],{"class":250},[237,890,638],{"class":261},[237,892,894],{"class":239,"line":893},48,[237,895,269],{"emptyLinePlaceholder":268},[237,897,899],{"class":239,"line":898},49,[237,900,269],{"emptyLinePlaceholder":268},[237,902,904,907,910,912,915,917,920,922],{"class":239,"line":903},50,[237,905,906],{"class":254},"RENDERERS",[237,908,909],{"class":261},": dict[Format, Callable[[Sequence[Row], Sequence[",[237,911,361],{"class":254},[237,913,914],{"class":261},"]], ",[237,916,361],{"class":254},[237,918,919],{"class":261},"]] ",[237,921,355],{"class":250},[237,923,924],{"class":261}," {\n",[237,926,928],{"class":239,"line":927},51,[237,929,930],{"class":261},"    Format.table: render_table,\n",[237,932,934],{"class":239,"line":933},52,[237,935,936],{"class":261},"    Format.json: render_json,\n",[237,938,940],{"class":239,"line":939},53,[237,941,942],{"class":261},"    Format.jsonl: render_jsonl,\n",[237,944,946],{"class":239,"line":945},54,[237,947,948],{"class":261},"    Format.csv: render_csv,\n",[237,950,952],{"class":239,"line":951},55,[237,953,954],{"class":261},"}\n",[237,956,958],{"class":239,"line":957},56,[237,959,269],{"emptyLinePlaceholder":268},[237,961,963],{"class":239,"line":962},57,[237,964,269],{"emptyLinePlaceholder":268},[237,966,968,970,973],{"class":239,"line":967},58,[237,969,457],{"class":250},[237,971,972],{"class":383}," default_format",[237,974,975],{"class":261},"() -> Format:\n",[237,977,979,981,984,987,990,993],{"class":239,"line":978},59,[237,980,635],{"class":250},[237,982,983],{"class":261}," Format.table ",[237,985,986],{"class":250},"if",[237,988,989],{"class":261}," sys.stdout.isatty() ",[237,991,992],{"class":250},"else",[237,994,995],{"class":261}," Format.jsonl\n",[10,997,998],{},"A command then looks like this:",[228,1000,1002],{"className":230,"code":1001,"language":232,"meta":233,"style":233},"# src\u002Fmytool\u002Fcli.py\nimport sys\n\nimport typer\n\nfrom mytool.output import RENDERERS, Format, default_format\n\napp = typer.Typer()\n\n\n@app.callback()\ndef main() -> None:\n    \"\"\"Fleet tool.\"\"\"\n\n\n@app.command(\"list\")\ndef list_servers(\n    output: Format | None = typer.Option(\n        None, \"--output\", \"-o\",\n        help=\"Output format (default: table on a terminal, jsonl in a pipe).\",\n    ),\n) -> None:\n    \"\"\"List servers.\"\"\"\n    rows = fetch_servers()                        # list[dict] with raw values\n    columns = [\"name\", \"region\", \"cpu\", \"status\"]\n    sys.stdout.write(RENDERERS[output or default_format()](rows, columns))\n",[14,1003,1004,1009,1015,1019,1026,1030,1045,1049,1059,1063,1067,1075,1089,1094,1098,1102,1114,1124,1141,1159,1171,1176,1185,1190,1203,1234],{"__ignoreMap":233},[237,1005,1006],{"class":239,"line":240},[237,1007,1008],{"class":243},"# src\u002Fmytool\u002Fcli.py\n",[237,1010,1011,1013],{"class":239,"line":247},[237,1012,275],{"class":250},[237,1014,302],{"class":261},[237,1016,1017],{"class":239,"line":265},[237,1018,269],{"emptyLinePlaceholder":268},[237,1020,1021,1023],{"class":239,"line":272},[237,1022,275],{"class":250},[237,1024,1025],{"class":261}," typer\n",[237,1027,1028],{"class":239,"line":281},[237,1029,269],{"emptyLinePlaceholder":268},[237,1031,1032,1034,1037,1039,1042],{"class":239,"line":289},[237,1033,251],{"class":250},[237,1035,1036],{"class":261}," mytool.output ",[237,1038,275],{"class":250},[237,1040,1041],{"class":254}," RENDERERS",[237,1043,1044],{"class":261},", Format, default_format\n",[237,1046,1047],{"class":239,"line":297},[237,1048,269],{"emptyLinePlaceholder":268},[237,1050,1051,1054,1056],{"class":239,"line":305},[237,1052,1053],{"class":261},"app ",[237,1055,355],{"class":250},[237,1057,1058],{"class":261}," typer.Typer()\n",[237,1060,1061],{"class":239,"line":318},[237,1062,269],{"emptyLinePlaceholder":268},[237,1064,1065],{"class":239,"line":331},[237,1066,269],{"emptyLinePlaceholder":268},[237,1068,1069,1072],{"class":239,"line":344},[237,1070,1071],{"class":383},"@app.callback",[237,1073,1074],{"class":261},"()\n",[237,1076,1077,1079,1082,1085,1087],{"class":239,"line":349},[237,1078,457],{"class":250},[237,1080,1081],{"class":383}," main",[237,1083,1084],{"class":261},"() -> ",[237,1086,533],{"class":254},[237,1088,473],{"class":261},[237,1090,1091],{"class":239,"line":367},[237,1092,1093],{"class":407},"    \"\"\"Fleet tool.\"\"\"\n",[237,1095,1096],{"class":239,"line":372},[237,1097,269],{"emptyLinePlaceholder":268},[237,1099,1100],{"class":239,"line":377},[237,1101,269],{"emptyLinePlaceholder":268},[237,1103,1104,1107,1109,1112],{"class":239,"line":399},[237,1105,1106],{"class":383},"@app.command",[237,1108,387],{"class":261},[237,1110,1111],{"class":407},"\"list\"",[237,1113,546],{"class":261},[237,1115,1116,1118,1121],{"class":239,"line":411},[237,1117,457],{"class":250},[237,1119,1120],{"class":383}," list_servers",[237,1122,1123],{"class":261},"(\n",[237,1125,1126,1129,1132,1135,1138],{"class":239,"line":422},[237,1127,1128],{"class":261},"    output: Format ",[237,1130,1131],{"class":250},"|",[237,1133,1134],{"class":254}," None",[237,1136,1137],{"class":250}," =",[237,1139,1140],{"class":261}," typer.Option(\n",[237,1142,1143,1146,1148,1151,1153,1156],{"class":239,"line":433},[237,1144,1145],{"class":254},"        None",[237,1147,76],{"class":261},[237,1149,1150],{"class":407},"\"--output\"",[237,1152,76],{"class":261},[237,1154,1155],{"class":407},"\"-o\"",[237,1157,1158],{"class":261},",\n",[237,1160,1161,1164,1166,1169],{"class":239,"line":444},[237,1162,1163],{"class":527},"        help",[237,1165,355],{"class":250},[237,1167,1168],{"class":407},"\"Output format (default: table on a terminal, jsonl in a pipe).\"",[237,1170,1158],{"class":261},[237,1172,1173],{"class":239,"line":449},[237,1174,1175],{"class":261},"    ),\n",[237,1177,1178,1181,1183],{"class":239,"line":454},[237,1179,1180],{"class":261},") -> ",[237,1182,533],{"class":254},[237,1184,473],{"class":261},[237,1186,1187],{"class":239,"line":476},[237,1188,1189],{"class":407},"    \"\"\"List servers.\"\"\"\n",[237,1191,1192,1195,1197,1200],{"class":239,"line":493},[237,1193,1194],{"class":261},"    rows ",[237,1196,355],{"class":250},[237,1198,1199],{"class":261}," fetch_servers()                        ",[237,1201,1202],{"class":243},"# list[dict] with raw values\n",[237,1204,1205,1208,1210,1213,1216,1218,1221,1223,1226,1228,1231],{"class":239,"line":506},[237,1206,1207],{"class":261},"    columns ",[237,1209,355],{"class":250},[237,1211,1212],{"class":261}," [",[237,1214,1215],{"class":407},"\"name\"",[237,1217,76],{"class":261},[237,1219,1220],{"class":407},"\"region\"",[237,1222,76],{"class":261},[237,1224,1225],{"class":407},"\"cpu\"",[237,1227,76],{"class":261},[237,1229,1230],{"class":407},"\"status\"",[237,1232,1233],{"class":261},"]\n",[237,1235,1236,1239,1241,1244,1247],{"class":239,"line":511},[237,1237,1238],{"class":261},"    sys.stdout.write(",[237,1240,906],{"class":254},[237,1242,1243],{"class":261},"[output ",[237,1245,1246],{"class":250},"or",[237,1248,1249],{"class":261}," default_format()](rows, columns))\n",[10,1251,1252,1253,1256,1257,1259,1260,1263,1264,1267,1268,1272],{},"Because ",[14,1254,1255],{},"Format"," is an ",[14,1258,225],{},", Typer lists the choices in ",[14,1261,1262],{},"--help"," and rejects ",[14,1265,1266],{},"-o xml"," with a clear usage error and exit code 2. Adding a format later means one new function and one dictionary entry — no command changes. ",[30,1269,1271],{"href":1270},"\u002Fadvanced-input-parsing-user-experience\u002Foutput-formats-for-data-clis\u002Fadding-a-format-flag-for-table-json-and-csv\u002F","Adding a format flag for table, JSON and CSV"," walks through this recipe end to end, including the Click version and the tests.",[54,1274,1276],{"id":1275},"choosing-the-default-format","Choosing the default format",[10,1278,1279],{},"The default is the format a user gets without asking, and it is the one most people will see. There are three defensible policies.",[50,1281],{"name":1282},"ofmt-default-decision",[10,1284,1285,1288,1289,1292,1293,1296],{},[65,1286,1287],{},"Always a table."," Simple and predictable: the output never changes shape depending on where it goes. The cost is that every script must remember ",[14,1290,1291],{},"-o json",", and a forgotten flag produces a table that a script then parses with ",[14,1294,1295],{},"awk"," — fragile code that breaks the first time a column widens.",[10,1298,1299,1302,1303,1306,1307,1310,1311,1313,1314,1317],{},[65,1300,1301],{},"Table on a terminal, machine format in a pipe."," This is what tools such as ",[14,1304,1305],{},"ls"," (one column when piped) and many modern CLIs do. It gives humans the table and scripts something parseable without any flag. The cost is surprise: ",[14,1308,1309],{},"mytool list | less"," shows JSON Lines instead of the table the user just saw. Mitigate it by making the rule visible in ",[14,1312,1262],{},", and by honouring an explicit ",[14,1315,1316],{},"-o table"," even in a pipe.",[10,1319,1320,1323,1324,1327,1328,1332],{},[65,1321,1322],{},"Configurable."," Let ",[14,1325,1326],{},"MYTOOL_OUTPUT=json"," or a config file key set the default, with the flag still winning. This suits teams where most users are scripting. It slots into the same precedence order the rest of your settings use; see ",[30,1329,1331],{"href":1330},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Fconfig-precedence-flags-env-files-defaults\u002F","config precedence: flags, env, files, defaults",".",[10,1334,1335,1336,1339,1340,1332],{},"The second policy plus the third's override is a good fit for most data CLIs. Whatever you choose, apply it in one function — ",[14,1337,1338],{},"default_format()"," above — rather than in each command, and use the same TTY detection as the rest of the tool, described in ",[30,1341,1343],{"href":1342},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fdetecting-tty-and-adapting-output\u002F","detecting a TTY and adapting output",[54,1345,1347],{"id":1346},"what-each-format-guarantees","What each format guarantees",[10,1349,1350],{},"Offering a format is a promise, and the details of the promise are what scripts break on. Write the guarantees down — in the help text or the docs — so that both you and your users know what may change.",[50,1352],{"name":1353},"ofmt-guarantees",[59,1355,1356,1363,1378,1387,1399],{},[62,1357,1358,1362],{},[65,1359,1360],{},[14,1361,75],{}," guarantees nothing to programs. Columns may be added, reordered, truncated or reformatted in any release. Say so in the docs, and point scripters at the machine formats.",[62,1364,1365,1369,1370,1373,1374,1377],{},[65,1366,1367],{},[14,1368,79],{}," is a single JSON document — an array of objects, or an object with a ",[14,1371,1372],{},"items"," key if you need room for metadata such as a pagination cursor. Keys are stable; new keys may appear; removing or renaming a key is a breaking change. Timestamps are ISO 8601 strings in UTC, sizes are integers in bytes, and ",[14,1375,1376],{},"null"," means \"no value\", not \"unknown\".",[62,1379,1380,1384,1385,1332],{},[65,1381,1382],{},[14,1383,82],{}," (JSON Lines, also called NDJSON) is one compact JSON object per line. It streams — a consumer can process line one before line ten thousand exists — which makes it the right default for pipes. The object shape is identical to the items in ",[14,1386,79],{},[62,1388,1389,1393,1394,1398],{},[65,1390,1391],{},[14,1392,85],{}," has a header row, RFC 4180 quoting and a fixed column order matching the selected fields. Nested values must be flattened or serialised; ",[30,1395,1397],{"href":1396},"\u002Fadvanced-input-parsing-user-experience\u002Foutput-formats-for-data-clis\u002Fwriting-csv-and-tsv-output-correctly\u002F","writing CSV and TSV output correctly"," covers quoting, encodings and the spreadsheet quirks.",[62,1400,1401,1405,1406,205,1409,1412],{},[65,1402,1403],{},[14,1404,88],{}," is the shell's format: one record per line, tab-separated, no quoting, with tabs and newlines inside values escaped. It is what ",[14,1407,1408],{},"cut -f2",[14,1410,1411],{},"while IFS=$'\\t' read -r name status"," expect.",[10,1414,1415,1416,1332],{},"Machine formats are part of your public interface in the same way flags are. Treat a renamed JSON key like a removed flag: deprecate, warn, and remove in a major version, as in ",[30,1417,1419],{"href":1418},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fversioning-and-deprecating-cli-flags\u002F","versioning and deprecating CLI flags",[54,1421,1423],{"id":1422},"choosing-fields-and-shaping-records","Choosing fields and shaping records",[10,1425,1426,1427,1429,1430,1433,1434,205,1437,1440],{},"Once every command returns records, a second set of options comes almost for free. ",[14,1428,24],{}," (some tools call it ",[14,1431,1432],{},"--columns",") chooses which keys to emit and in what order; it applies to every format, so ",[14,1435,1436],{},"-o csv --fields name,cpu",[14,1438,1439],{},"-o table --fields name,cpu"," show the same two columns.",[228,1442,1444],{"className":230,"code":1443,"language":232,"meta":233,"style":233},"def select_columns(available: Sequence[str], requested: str | None) -> list[str]:\n    if not requested:\n        return list(available)\n    wanted = [f.strip() for f in requested.split(\",\") if f.strip()]\n    unknown = [f for f in wanted if f not in available]\n    if unknown:\n        raise typer.BadParameter(\n            f\"unknown field(s): {', '.join(unknown)}; choose from {', '.join(available)}\",\n            param_hint=\"--fields\",\n        )\n    return wanted\n",[14,1445,1446,1476,1487,1498,1528,1560,1567,1575,1611,1623,1628],{"__ignoreMap":233},[237,1447,1448,1450,1453,1456,1458,1461,1463,1466,1468,1471,1473],{"class":239,"line":240},[237,1449,457],{"class":250},[237,1451,1452],{"class":383}," select_columns",[237,1454,1455],{"class":261},"(available: Sequence[",[237,1457,361],{"class":254},[237,1459,1460],{"class":261},"], requested: ",[237,1462,361],{"class":254},[237,1464,1465],{"class":250}," |",[237,1467,1134],{"class":254},[237,1469,1470],{"class":261},") -> list[",[237,1472,361],{"class":254},[237,1474,1475],{"class":261},"]:\n",[237,1477,1478,1481,1484],{"class":239,"line":247},[237,1479,1480],{"class":250},"    if",[237,1482,1483],{"class":250}," not",[237,1485,1486],{"class":261}," requested:\n",[237,1488,1489,1492,1495],{"class":239,"line":265},[237,1490,1491],{"class":250},"        return",[237,1493,1494],{"class":254}," list",[237,1496,1497],{"class":261},"(available)\n",[237,1499,1500,1503,1505,1508,1510,1513,1515,1518,1521,1523,1525],{"class":239,"line":272},[237,1501,1502],{"class":261},"    wanted ",[237,1504,355],{"class":250},[237,1506,1507],{"class":261}," [f.strip() ",[237,1509,585],{"class":250},[237,1511,1512],{"class":261}," f ",[237,1514,558],{"class":250},[237,1516,1517],{"class":261}," requested.split(",[237,1519,1520],{"class":407},"\",\"",[237,1522,704],{"class":261},[237,1524,986],{"class":250},[237,1526,1527],{"class":261}," f.strip()]\n",[237,1529,1530,1533,1535,1538,1540,1542,1544,1547,1549,1551,1554,1557],{"class":239,"line":281},[237,1531,1532],{"class":261},"    unknown ",[237,1534,355],{"class":250},[237,1536,1537],{"class":261}," [f ",[237,1539,585],{"class":250},[237,1541,1512],{"class":261},[237,1543,558],{"class":250},[237,1545,1546],{"class":261}," wanted ",[237,1548,986],{"class":250},[237,1550,1512],{"class":261},[237,1552,1553],{"class":250},"not",[237,1555,1556],{"class":250}," in",[237,1558,1559],{"class":261}," available]\n",[237,1561,1562,1564],{"class":239,"line":289},[237,1563,1480],{"class":250},[237,1565,1566],{"class":261}," unknown:\n",[237,1568,1569,1572],{"class":239,"line":297},[237,1570,1571],{"class":250},"        raise",[237,1573,1574],{"class":261}," typer.BadParameter(\n",[237,1576,1577,1580,1583,1586,1589,1592,1595,1598,1600,1602,1605,1607,1609],{"class":239,"line":305},[237,1578,1579],{"class":250},"            f",[237,1581,1582],{"class":407},"\"unknown field(s): ",[237,1584,1585],{"class":254},"{",[237,1587,1588],{"class":407},"', '",[237,1590,1591],{"class":261},".join(unknown)",[237,1593,1594],{"class":254},"}",[237,1596,1597],{"class":407},"; choose from ",[237,1599,1585],{"class":254},[237,1601,1588],{"class":407},[237,1603,1604],{"class":261},".join(available)",[237,1606,1594],{"class":254},[237,1608,773],{"class":407},[237,1610,1158],{"class":261},[237,1612,1613,1616,1618,1621],{"class":239,"line":318},[237,1614,1615],{"class":527},"            param_hint",[237,1617,355],{"class":250},[237,1619,1620],{"class":407},"\"--fields\"",[237,1622,1158],{"class":261},[237,1624,1625],{"class":239,"line":331},[237,1626,1627],{"class":261},"        )\n",[237,1629,1630,1632],{"class":239,"line":344},[237,1631,635],{"class":250},[237,1633,1634],{"class":261}," wanted\n",[10,1636,1637,1638,1641,1642,1646],{},"Validating against the known columns matters: a typo that silently yields an empty column is worse than an error, because the script that depends on it keeps running with blanks. Nested data needs a rule too — either flatten with dotted names (",[14,1639,1640],{},"owner.email",") or refuse nested fields in flat formats. ",[30,1643,1645],{"href":1644},"\u002Fadvanced-input-parsing-user-experience\u002Foutput-formats-for-data-clis\u002Fselecting-fields-and-columns-from-cli-output\u002F","Selecting fields and columns from CLI output"," covers dotted paths, wildcards and sorting.",[10,1648,1649,1650,1653,1654,1657,1658,1662],{},"For the shell loop that wants exactly one string per record, a template format beats any amount of field selection. Docker, kubectl and the GitHub CLI all offer a variant of ",[14,1651,1652],{},"--format '{{.Name}}'",". In Python, ",[14,1655,1656],{},"str.format_map"," with a restricted mapping gives the same power with a syntax your users already know from f-strings — without opening the door to arbitrary attribute access. ",[30,1659,1661],{"href":1660},"\u002Fadvanced-input-parsing-user-experience\u002Foutput-formats-for-data-clis\u002Fcustom-output-templates-with-a-format-string\u002F","Custom output templates with a format string"," shows how to build it safely.",[54,1664,1666],{"id":1665},"writing-to-files-as-well-as-stdout","Writing to files as well as stdout",[10,1668,1669,1670,1672,1673,1676,1677,1680],{},"Most of the time stdout is the right destination: the shell already knows how to redirect it. But two cases justify an explicit ",[14,1671,218],{}," (or ",[14,1674,1675],{},"--export",") option. The first is Windows, where redirecting with ",[14,1678,1679],{},">"," in PowerShell 5 re-encodes output to UTF-16 and mangles CSV for every consumer. The second is any command that also prints progress or prompts: once the data goes to a named file, the terminal is free for the human-facing feedback.",[50,1682],{"name":1683},"ofmt-file-export",[10,1685,1686,1687,1690,1691,1693,1694,1697,1698,1702,1703,1706,1707,1711],{},"When a file path is given, three extra rules apply. Infer the format from the extension (",[14,1688,1689],{},"report.csv"," → ",[14,1692,85],{},") unless ",[14,1695,1696],{},"-o"," says otherwise. Write atomically so a crash never leaves half a CSV, as in ",[30,1699,1701],{"href":1700},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fwriting-files-atomically-in-python-clis\u002F","writing files atomically in Python CLIs",". And treat ",[14,1704,1705],{},"-"," as stdout, so scripts can use one code path for both. ",[30,1708,1710],{"href":1709},"\u002Fadvanced-input-parsing-user-experience\u002Foutput-formats-for-data-clis\u002Fexporting-cli-results-to-files\u002F","Exporting CLI results to files"," implements all three.",[54,1713,1715],{"id":1714},"large-result-sets-and-streaming","Large result sets and streaming",[10,1717,1718,1719,76,1721,205,1723,1725],{},"The renderer signature above takes a fully materialised list. That is fine for a few thousand rows and simplifies tables, which need every row to compute column widths. For commands that can return millions of records, change the contract for the streaming formats: give ",[14,1720,82],{},[14,1722,85],{},[14,1724,88],{}," renderers an iterator and have them write each row as it arrives.",[228,1727,1729],{"className":230,"code":1728,"language":232,"meta":233,"style":233},"from collections.abc import Iterable\nfrom typing import TextIO\n\ndef stream_jsonl(rows: Iterable[Row], columns: Sequence[str], out: TextIO) -> None:\n    for row in rows:\n        out.write(json.dumps({c: row.get(c) for c in columns}) + \"\\n\")\n",[14,1730,1731,1742,1753,1757,1776,1786],{"__ignoreMap":233},[237,1732,1733,1735,1737,1739],{"class":239,"line":240},[237,1734,251],{"class":250},[237,1736,310],{"class":261},[237,1738,275],{"class":250},[237,1740,1741],{"class":261}," Iterable\n",[237,1743,1744,1746,1748,1750],{"class":239,"line":247},[237,1745,251],{"class":250},[237,1747,336],{"class":261},[237,1749,275],{"class":250},[237,1751,1752],{"class":261}," TextIO\n",[237,1754,1755],{"class":239,"line":265},[237,1756,269],{"emptyLinePlaceholder":268},[237,1758,1759,1761,1764,1767,1769,1772,1774],{"class":239,"line":272},[237,1760,457],{"class":250},[237,1762,1763],{"class":383}," stream_jsonl",[237,1765,1766],{"class":261},"(rows: Iterable[Row], columns: Sequence[",[237,1768,361],{"class":254},[237,1770,1771],{"class":261},"], out: TextIO) -> ",[237,1773,533],{"class":254},[237,1775,473],{"class":261},[237,1777,1778,1780,1782,1784],{"class":239,"line":281},[237,1779,552],{"class":250},[237,1781,555],{"class":261},[237,1783,558],{"class":250},[237,1785,561],{"class":261},[237,1787,1788,1791,1793,1795,1797,1799,1801,1803,1805,1807],{"class":239,"line":289},[237,1789,1790],{"class":261},"        out.write(json.dumps({c: row.get(c) ",[237,1792,585],{"class":250},[237,1794,588],{"class":261},[237,1796,558],{"class":250},[237,1798,764],{"class":261},[237,1800,707],{"class":250},[237,1802,710],{"class":407},[237,1804,713],{"class":254},[237,1806,773],{"class":407},[237,1808,546],{"class":261},[10,1810,1811,1812,205,1814,1816,1817,1819,1820,1824,1825,1829,1830,1833],{},"With that split, memory stays flat for the machine formats and only ",[14,1813,75],{},[14,1815,79],{}," (which must close the array) buffer. If a command can produce unbounded output, consider refusing ",[14,1818,1316],{}," above a row count, or truncating with a clear \"showing 1,000 of 2.3 million rows; use -o jsonl for all\" footer. The NDJSON patterns in ",[30,1821,1823],{"href":1822},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fprocessing-large-files-and-ndjson-streams\u002F","processing large files and NDJSON streams"," apply directly, and so does the ",[30,1826,1828],{"href":1827},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fhandling-broken-pipe-and-sigpipe\u002F","broken pipe handling"," that keeps ",[14,1831,1832],{},"mytool list -o jsonl | head"," from printing a traceback.",[54,1835,1837],{"id":1836},"testing-every-format","Testing every format",[10,1839,1840,1841,1844,1845,1848],{},"Output formats fail in the details: an unquoted comma, a ",[14,1842,1843],{},"\\r\\n"," that a Unix test never sees, a float printed as ",[14,1846,1847],{},"1e-05",", a key renamed by an innocent refactor. Unit-test the renderers directly with awkward data, and snapshot-test each command once per format.",[228,1850,1852],{"className":230,"code":1851,"language":232,"meta":233,"style":233},"import csv\nimport io\nimport json\n\nfrom mytool.output import render_csv, render_jsonl\n\nAWKWARD = [{\"name\": 'a \"quoted\", name', \"note\": \"line1\\nline2\", \"n\": 3}]\n\n\ndef test_csv_round_trips_awkward_values():\n    text = render_csv(AWKWARD, [\"name\", \"note\", \"n\"])\n    assert list(csv.DictReader(io.StringIO(text))) == [\n        {\"name\": 'a \"quoted\", name', \"note\": \"line1\\nline2\", \"n\": \"3\"}\n    ]\n\n\ndef test_jsonl_is_one_object_per_line():\n    lines = render_jsonl(AWKWARD * 3, [\"name\", \"n\"]).splitlines()\n    assert len(lines) == 3\n    assert all(json.loads(line)[\"n\"] == 3 for line in lines)\n",[14,1853,1854,1860,1866,1872,1876,1887,1891,1937,1941,1945,1955,1983,1999,2033,2038,2042,2046,2055,2084,2099],{"__ignoreMap":233},[237,1855,1856,1858],{"class":239,"line":240},[237,1857,275],{"class":250},[237,1859,278],{"class":261},[237,1861,1862,1864],{"class":239,"line":247},[237,1863,275],{"class":250},[237,1865,286],{"class":261},[237,1867,1868,1870],{"class":239,"line":265},[237,1869,275],{"class":250},[237,1871,294],{"class":261},[237,1873,1874],{"class":239,"line":272},[237,1875,269],{"emptyLinePlaceholder":268},[237,1877,1878,1880,1882,1884],{"class":239,"line":281},[237,1879,251],{"class":250},[237,1881,1036],{"class":261},[237,1883,275],{"class":250},[237,1885,1886],{"class":261}," render_csv, render_jsonl\n",[237,1888,1889],{"class":239,"line":289},[237,1890,269],{"emptyLinePlaceholder":268},[237,1892,1893,1896,1898,1901,1903,1906,1909,1911,1914,1916,1919,1921,1924,1926,1929,1931,1934],{"class":239,"line":297},[237,1894,1895],{"class":254},"AWKWARD",[237,1897,1137],{"class":250},[237,1899,1900],{"class":261}," [{",[237,1902,1215],{"class":407},[237,1904,1905],{"class":261},": ",[237,1907,1908],{"class":407},"'a \"quoted\", name'",[237,1910,76],{"class":261},[237,1912,1913],{"class":407},"\"note\"",[237,1915,1905],{"class":261},[237,1917,1918],{"class":407},"\"line1",[237,1920,713],{"class":254},[237,1922,1923],{"class":407},"line2\"",[237,1925,76],{"class":261},[237,1927,1928],{"class":407},"\"n\"",[237,1930,1905],{"class":261},[237,1932,1933],{"class":254},"3",[237,1935,1936],{"class":261},"}]\n",[237,1938,1939],{"class":239,"line":305},[237,1940,269],{"emptyLinePlaceholder":268},[237,1942,1943],{"class":239,"line":318},[237,1944,269],{"emptyLinePlaceholder":268},[237,1946,1947,1949,1952],{"class":239,"line":331},[237,1948,457],{"class":250},[237,1950,1951],{"class":383}," test_csv_round_trips_awkward_values",[237,1953,1954],{"class":261},"():\n",[237,1956,1957,1960,1962,1965,1967,1970,1972,1974,1976,1978,1980],{"class":239,"line":344},[237,1958,1959],{"class":261},"    text ",[237,1961,355],{"class":250},[237,1963,1964],{"class":261}," render_csv(",[237,1966,1895],{"class":254},[237,1968,1969],{"class":261},", [",[237,1971,1215],{"class":407},[237,1973,76],{"class":261},[237,1975,1913],{"class":407},[237,1977,76],{"class":261},[237,1979,1928],{"class":407},[237,1981,1982],{"class":261},"])\n",[237,1984,1985,1988,1990,1993,1996],{"class":239,"line":349},[237,1986,1987],{"class":250},"    assert",[237,1989,1494],{"class":254},[237,1991,1992],{"class":261},"(csv.DictReader(io.StringIO(text))) ",[237,1994,1995],{"class":250},"==",[237,1997,1998],{"class":261}," [\n",[237,2000,2001,2004,2006,2008,2010,2012,2014,2016,2018,2020,2022,2024,2026,2028,2031],{"class":239,"line":367},[237,2002,2003],{"class":261},"        {",[237,2005,1215],{"class":407},[237,2007,1905],{"class":261},[237,2009,1908],{"class":407},[237,2011,76],{"class":261},[237,2013,1913],{"class":407},[237,2015,1905],{"class":261},[237,2017,1918],{"class":407},[237,2019,713],{"class":254},[237,2021,1923],{"class":407},[237,2023,76],{"class":261},[237,2025,1928],{"class":407},[237,2027,1905],{"class":261},[237,2029,2030],{"class":407},"\"3\"",[237,2032,954],{"class":261},[237,2034,2035],{"class":239,"line":372},[237,2036,2037],{"class":261},"    ]\n",[237,2039,2040],{"class":239,"line":377},[237,2041,269],{"emptyLinePlaceholder":268},[237,2043,2044],{"class":239,"line":399},[237,2045,269],{"emptyLinePlaceholder":268},[237,2047,2048,2050,2053],{"class":239,"line":411},[237,2049,457],{"class":250},[237,2051,2052],{"class":383}," test_jsonl_is_one_object_per_line",[237,2054,1954],{"class":261},[237,2056,2057,2060,2062,2065,2067,2070,2073,2075,2077,2079,2081],{"class":239,"line":422},[237,2058,2059],{"class":261},"    lines ",[237,2061,355],{"class":250},[237,2063,2064],{"class":261}," render_jsonl(",[237,2066,1895],{"class":254},[237,2068,2069],{"class":250}," *",[237,2071,2072],{"class":254}," 3",[237,2074,1969],{"class":261},[237,2076,1215],{"class":407},[237,2078,76],{"class":261},[237,2080,1928],{"class":407},[237,2082,2083],{"class":261},"]).splitlines()\n",[237,2085,2086,2088,2091,2094,2096],{"class":239,"line":433},[237,2087,1987],{"class":250},[237,2089,2090],{"class":254}," len",[237,2092,2093],{"class":261},"(lines) ",[237,2095,1995],{"class":250},[237,2097,2098],{"class":254}," 3\n",[237,2100,2101,2103,2106,2109,2111,2114,2116,2118,2120,2123,2125],{"class":239,"line":444},[237,2102,1987],{"class":250},[237,2104,2105],{"class":254}," all",[237,2107,2108],{"class":261},"(json.loads(line)[",[237,2110,1928],{"class":407},[237,2112,2113],{"class":261},"] ",[237,2115,1995],{"class":250},[237,2117,2072],{"class":254},[237,2119,776],{"class":250},[237,2121,2122],{"class":261}," line ",[237,2124,558],{"class":250},[237,2126,2127],{"class":261}," lines)\n",[10,2129,2130,2131,2135],{},"Round-trip tests — render, then parse with the standard library and compare — catch quoting bugs without hard-coding the escaping rules. For the command level, store one snapshot per format so that a changed key shows up as a diff in review; see ",[30,2132,2134],{"href":2133},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fsnapshot-testing-cli-output\u002F","snapshot testing CLI output"," for the tooling.",[54,2137,2139],{"id":2138},"common-pitfalls","Common pitfalls",[59,2141,2142,2151,2161,2171,2194],{},[62,2143,2144,2147,2148,1332],{},[65,2145,2146],{},"Colour codes in machine formats."," Rich and Click both strip colour when stdout is not a TTY, but only if you write through them. A JSON renderer must never use the coloured console; write plain strings to ",[14,2149,2150],{},"sys.stdout",[62,2152,2153,2156,2157,1332],{},[65,2154,2155],{},"Logs on stdout."," Progress messages or warnings printed to stdout corrupt every machine format. Send all diagnostics to stderr, always, as described in ",[30,2158,2160],{"href":2159},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002F","structured logging for CLI apps",[62,2162,2163,2166,2167,2170],{},[65,2164,2165],{},"Locale-dependent numbers."," Never format numbers with the locale in machine output; ",[14,2168,2169],{},"1.234,5"," is valid in a German table and a parse error in a JSON consumer.",[62,2172,2173,2176,2177,2179,2180,205,2183,2185,2186,2189,2190,2193],{},[65,2174,2175],{},"Different columns per format."," If ",[14,2178,1316],{}," shows ",[14,2181,2182],{},"age",[14,2184,1291],{}," has ",[14,2187,2188],{},"created_at",", scripts cannot use the table to discover field names. Keep column names identical; let only the ",[189,2191,2192],{},"values"," be humanised in the table.",[62,2195,2196,2199,2200,2202,2203,2206,2207,2209],{},[65,2197,2198],{},"An empty result that is not valid output."," An empty ",[14,2201,79],{}," result must be ",[14,2204,2205],{},"[]",", an empty ",[14,2208,85],{}," result should still have the header row, and an empty table should print a short message to stderr rather than nothing at all.",[54,2211,2213],{"id":2212},"key-takeaways","Key takeaways",[59,2215,2216,2219,2228,2231,2234,2240],{},[62,2217,2218],{},"Model output as records plus a column list, and put every formatting decision in one shared renderer layer.",[62,2220,2221,2222,2225,2226,1332],{},"Offer one ",[14,2223,2224],{},"--output"," option with a closed set of choices, validated by an ",[14,2227,225],{},[62,2229,2230],{},"Default to a table for terminals and JSON Lines for pipes, and let users override the default.",[62,2232,2233],{},"Treat JSON, JSON Lines, CSV and TSV as a stable interface with documented guarantees.",[62,2235,2236,2237,2239],{},"Build ",[14,2238,24],{},", templates and file export on top of the same records so every format benefits.",[62,2241,2242],{},"Snapshot and round-trip test each format with deliberately awkward data.",[54,2244,2246],{"id":2245},"frequently-asked-questions","Frequently asked questions",[2248,2249,2251,2252,2254,2255,2258],"h3",{"id":2250},"should-i-use-json-or-output-json","Should I use ",[14,2253,20],{}," or ",[14,2256,2257],{},"--output json","?",[10,2260,2261,2262,2264,2265,2267,2268,2270,2271,1332],{},"Use ",[14,2263,2257],{}," (with ",[14,2266,1696],{}," as the short form) when you offer more than one machine format, because it scales to new formats without new flags and makes the choices mutually exclusive by construction. A single ",[14,2269,20],{}," boolean is fine for a tool that will only ever have one machine format, and many tools offer it as an alias for ",[14,2272,1291],{},[2248,2274,2276],{"id":2275},"is-yaml-worth-offering","Is YAML worth offering?",[10,2278,2279,2280,2283],{},"Only if your users already live in YAML — Kubernetes and Ansible tooling, for example. YAML output is mostly for reading, and JSON is valid YAML anyway. If you add it, render it with ",[14,2281,2282],{},"yaml.safe_dump(..., sort_keys=False)"," and keep the same keys as JSON.",[2248,2285,2287],{"id":2286},"should-machine-output-include-metadata-such-as-totals-or-a-next-page-cursor","Should machine output include metadata such as totals or a next-page cursor?",[10,2289,2290,2291,2293,2294,2297,2298,205,2300,2302],{},"In ",[14,2292,79],{},", wrap the list in an object (",[14,2295,2296],{},"{\"items\": [...], \"next_cursor\": \"...\"}",") from the very first release, because moving from a bare array to an object later is a breaking change. In ",[14,2299,82],{},[14,2301,85],{},", keep the stream to pure records and put metadata on stderr or behind a separate flag.",[2248,2304,2306],{"id":2305},"how-do-i-keep-the-table-readable-on-a-narrow-terminal","How do I keep the table readable on a narrow terminal?",[10,2308,2309,2310,2314],{},"Let the table renderer — and only the table renderer — truncate and wrap. Rich does this automatically when it knows the console width. ",[30,2311,2313],{"href":2312},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fadapting-output-to-terminal-width\u002F","Adapting output to terminal width"," covers choosing which columns to drop first.",[2248,2316,2318],{"id":2317},"does-every-command-need-every-format","Does every command need every format?",[10,2320,2321,2322,2325,2326,2328],{},"Every command that returns a ",[189,2323,2324],{},"list of records"," should support the same set, so users can rely on it. Commands that perform an action and print a confirmation need at most a ",[14,2327,79],{}," result for scripts; a table makes no sense there.",[54,2330,2332],{"id":2331},"related","Related",[59,2334,2335,2340,2345,2350,2354,2358,2362,2368,2373],{},[62,2336,2337,2338],{},"Up: ",[30,2339,33],{"href":32},[62,2341,2342,2343],{},"Down: ",[30,2344,1271],{"href":1270},[62,2346,2342,2347],{},[30,2348,2349],{"href":1396},"Writing CSV and TSV output correctly",[62,2351,2342,2352],{},[30,2353,1645],{"href":1644},[62,2355,2342,2356],{},[30,2357,1661],{"href":1660},[62,2359,2342,2360],{},[30,2361,1710],{"href":1709},[62,2363,2364,2365],{},"Sideways: ",[30,2366,2367],{"href":37},"Working with stdin, stdout and pipes",[62,2369,2364,2370],{},[30,2371,2372],{"href":42},"Interactive terminal UI with Rich",[62,2374,2364,2375],{},[30,2376,2378],{"href":2377},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Femitting-json-output-for-scripting\u002F","Emitting JSON output for scripting",[2380,2381,2382],"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":233,"searchDepth":247,"depth":247,"links":2384},[2385,2386,2387,2388,2389,2390,2391,2392,2393,2394,2395,2396,2404],{"id":56,"depth":247,"text":57},{"id":133,"depth":247,"text":134},{"id":171,"depth":247,"text":172},{"id":1275,"depth":247,"text":1276},{"id":1346,"depth":247,"text":1347},{"id":1422,"depth":247,"text":1423},{"id":1665,"depth":247,"text":1666},{"id":1714,"depth":247,"text":1715},{"id":1836,"depth":247,"text":1837},{"id":2138,"depth":247,"text":2139},{"id":2212,"depth":247,"text":2213},{"id":2245,"depth":247,"text":2246,"children":2397},[2398,2400,2401,2402,2403],{"id":2250,"depth":265,"text":2399},"Should I use --json or --output json?",{"id":2275,"depth":265,"text":2276},{"id":2286,"depth":265,"text":2287},{"id":2305,"depth":265,"text":2306},{"id":2317,"depth":265,"text":2318},{"id":2331,"depth":247,"text":2332},"2026-10-02","Give a Python CLI table, JSON, JSON Lines, CSV and template output behind one --output flag, with field selection, file export and tests that pin every format.","intermediate",false,"md",{},"\u002Fadvanced-input-parsing-user-experience\u002Foutput-formats-for-data-clis",{"title":5,"description":2406},"advanced-input-parsing-user-experience\u002Foutput-formats-for-data-clis\u002Findex",[2415,79,85,2416,2417],"output","formats","scripting","6i4ef2mLo8MbjUZ5w365V-VSwnDxgRo2WnAwWQTMFos",[2420,2423,2426,2429,2432,2435,2438,2441,2444,2447,2450,2453,2456,2459,2462,2465,2468,2471,2474,2477,2480,2483,2486,2489,2492,2495,2498,2501,2504,2507,2510,2513,2516,2519,2522,2525,2528,2531,2534,2537,2540,2543,2546,2549,2552,2555,2558,2561,2564,2567,2570,2573,2576,2579,2582,2585,2588,2591,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,2868,2871,2874,2877,2880,2883,2886,2889,2892,2895,2898,2901,2904,2907,2910,2913,2916,2919,2922,2925,2928,2931,2934,2937,2940,2943,2946,2949,2952,2955,2958,2961,2964,2967,2970,2973,2976,2979,2982,2985,2988,2991,2994,2997,3000,3003,3006,3009,3012,3015,3018,3021,3024,3027,3030,3033,3036,3039,3042,3045,3048,3051,3054,3057,3060,3063,3066,3069,3072,3075,3078,3081,3084,3087,3090,3093,3096,3099,3102,3105,3108,3111,3114,3117,3120,3123,3126,3129,3132,3135,3138,3141,3144,3147,3150,3153,3156,3159,3162,3165,3168,3171,3174,3177,3180,3183,3186,3189,3192,3195,3198,3201,3204,3207,3210,3213,3216,3219,3222,3225,3228,3231,3234,3237,3240,3243,3246,3249,3252,3255,3258,3261],{"path":2421,"title":2422},"\u002Fabout","About Python CLI Toolcraft",{"path":2424,"title":2425},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies","Advanced Argument Validation Strategies",{"path":2427,"title":2428},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fparsing-nested-json-arguments-in-python-clis","Parsing Nested JSON Args in Python CLIs",{"path":2430,"title":2431},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-dates-and-durations-in-cli-arguments","Validating Dates and Durations in Python CLI Arguments",{"path":2433,"title":2434},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-dependent-and-conflicting-options","Validating Dependent and Conflicting CLI Options",{"path":2436,"title":2437},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-file-and-directory-paths-in-clis","Validating File and Directory Paths in CLIs",{"path":2439,"title":2440},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-urls-hosts-and-ports","Validating URLs, Hosts and Ports in Python CLI Arguments",{"path":2442,"title":2443},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fwriting-custom-click-parameter-types","Writing Custom Click Parameter Types",{"path":2445,"title":2446},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual\u002Fbrowsing-records-with-a-textual-datatable","Browsing Records with a Textual DataTable Picker",{"path":2448,"title":2449},"\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":2451,"title":2452},"\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":2454,"title":2455},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual","Building Terminal UIs with Textual for Python CLIs",{"path":2457,"title":2458},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual\u002Frunning-background-work-in-textual-with-workers","Running Background Work in Textual with Workers",{"path":2460,"title":2461},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual\u002Fstyling-textual-apps-with-tcss","Styling Textual Apps with TCSS",{"path":2463,"title":2464},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual\u002Ftesting-textual-apps-with-pilot","Testing Textual Apps with Pilot",{"path":2466,"title":2467},"\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":2469,"title":2470},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fdocumenting-environment-variables-in-help","Documenting Environment Variables in CLI Help",{"path":2472,"title":2473},"\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":2475,"title":2476},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation","CLI Help Output and Documentation",{"path":2478,"title":2479},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Frich-formatted-help-with-rich-click","Rich-Formatted Help for Click CLIs with rich-click",{"path":2481,"title":2482},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fversioning-and-deprecating-cli-flags","Versioning and Deprecating CLI Flags",{"path":2484,"title":2485},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fwriting-help-text-users-actually-read","Writing Help Text Users Actually Read",{"path":2487,"title":2488},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fadapting-output-to-terminal-width","Adapting Python CLI Output to Terminal Width",{"path":2490,"title":2491},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fdetecting-ci-environments-and-non-interactive-shells","Detecting CI Environments and Non-Interactive Shells",{"path":2493,"title":2494},"\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":2496,"title":2497},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fhandling-ansi-escape-codes-on-windows-consoles","Handling ANSI Escape Codes on Windows Consoles",{"path":2499,"title":2500},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility","Cross-Platform Terminal Compatibility for Python CLIs",{"path":2502,"title":2503},"\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":2505,"title":2506},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fsupporting-dumb-terminals-and-screen-readers","Supporting Dumb Terminals and Screen Readers in a Python CLI",{"path":2508,"title":2509},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fchoosing-exit-codes-for-cli-tools","Choosing Exit Codes for CLI Tools",{"path":2511,"title":2512},"\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":2514,"title":2515},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fdid-you-mean-suggestions-for-mistyped-input","Did You Mean…? Suggestions for Mistyped CLI Input",{"path":2517,"title":2518},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Ffriendly-error-messages-and-tracebacks","Friendly Error Messages and Tracebacks",{"path":2520,"title":2521},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fhandling-keyboard-interrupt-cleanly","Handling Keyboard Interrupt Cleanly",{"path":2523,"title":2524},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes","Error Handling and Exit Codes for CLIs",{"path":2526,"title":2527},"\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":2529,"title":2530},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fwriting-crash-reports-users-can-send","Writing Crash Reports Users Can Send",{"path":2532,"title":2533},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Fconfig-precedence-flags-env-files-defaults","Config Precedence: Flags, Env, Files, Defaults",{"path":2535,"title":2536},"\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":2538,"title":2539},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars","Handling Config Files and Env Vars in CLIs",{"path":2541,"title":2542},"\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":2544,"title":2545},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Freading-toml-config-with-tomllib","Reading TOML Config with tomllib in Python CLIs",{"path":2547,"title":2548},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Ftyped-settings-with-pydantic-settings","Typed Settings with pydantic-settings in Python CLIs",{"path":2550,"title":2551},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Fvalidating-config-files-with-json-schema","Validating Config Files with JSON Schema in a Python CLI",{"path":2553,"title":2554},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Fwriting-a-config-init-and-edit-command","Writing a Config Init and Edit Command for a Python CLI",{"path":2556,"title":2557},"\u002Fadvanced-input-parsing-user-experience","Advanced Input Parsing for Python CLIs",{"path":2559,"title":2560},"\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":2562,"title":2563},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Fbuilding-interactive-prompts-and-menus","Building Interactive Prompts and Menus in Python CLIs",{"path":2565,"title":2566},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Fbuilding-tree-views-with-rich","Building Tree Views with Rich in a Python CLI",{"path":2568,"title":2569},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich","Interactive Terminal UI with Rich",{"path":2571,"title":2572},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Flive-dashboards-with-rich-live","Live Dashboards with Rich Live in Python CLIs",{"path":2574,"title":2575},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Frendering-markdown-and-syntax-highlighting-with-rich","Rendering Markdown and Syntax Highlighting with Rich",{"path":2577,"title":2578},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Frendering-tables-and-json-with-rich","Rendering Tables and JSON with Rich",{"path":2580,"title":2581},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Ftheming-rich-output-consistently","Theming Rich Output Consistently in Python CLIs",{"path":2583,"title":2584},"\u002Fadvanced-input-parsing-user-experience\u002Foutput-formats-for-data-clis\u002Fadding-a-format-flag-for-table-json-and-csv","Adding a Format Flag for Table, JSON and CSV Output",{"path":2586,"title":2587},"\u002Fadvanced-input-parsing-user-experience\u002Foutput-formats-for-data-clis\u002Fcustom-output-templates-with-a-format-string","Custom Output Templates with a Format String in Python CLIs",{"path":2589,"title":2590},"\u002Fadvanced-input-parsing-user-experience\u002Foutput-formats-for-data-clis\u002Fexporting-cli-results-to-files","Exporting CLI Results to Files from a Python CLI",{"path":2411,"title":5},{"path":2593,"title":2594},"\u002Fadvanced-input-parsing-user-experience\u002Foutput-formats-for-data-clis\u002Fselecting-fields-and-columns-from-cli-output","Selecting Fields and Columns from Python CLI Output",{"path":2596,"title":2597},"\u002Fadvanced-input-parsing-user-experience\u002Foutput-formats-for-data-clis\u002Fwriting-csv-and-tsv-output-correctly","Writing CSV and TSV Output Correctly from a Python CLI",{"path":2599,"title":2600},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis\u002Fargcomplete-for-argparse-clis","Tab Completion for argparse CLIs with argcomplete",{"path":2602,"title":2603},"\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":2605,"title":2606},"\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":2608,"title":2609},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis","Shell Completion for Python CLIs",{"path":2611,"title":2612},"\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":2614,"title":2615},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis\u002Fshipping-completion-scripts-with-packages","Shipping Shell Completion Scripts with a Python CLI",{"path":2617,"title":2618},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis\u002Ftesting-shell-completion-in-python-clis","Testing Shell Completion in Python CLIs",{"path":2620,"title":2621},"\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":2623,"title":2624},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Fadding-verbose-and-quiet-logging-flags","Adding Verbose and Quiet Logging Flags",{"path":2626,"title":2627},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps","Structured Logging for CLI Apps",{"path":2629,"title":2630},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Flogging-with-structlog-in-a-cli","Logging with structlog in a Python CLI",{"path":2632,"title":2633},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Fseparating-logs-from-program-output","Separating Logs from Program Output in a Python CLI",{"path":2635,"title":2636},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Fstructured-json-logging-in-python-clis","Structured JSON Logging in Python CLIs",{"path":2638,"title":2639},"\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":2641,"title":2642},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fdetecting-tty-and-adapting-output","Detecting a TTY and Adapting Output",{"path":2644,"title":2645},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Femitting-json-output-for-scripting","Emitting JSON Output for Scripting",{"path":2647,"title":2648},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fhandling-broken-pipe-and-sigpipe","Handling Broken Pipe and SIGPIPE",{"path":2650,"title":2651},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes","Working with stdin, stdout and Pipes",{"path":2653,"title":2654},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fnull-delimited-input-and-xargs-compatibility","Null-Delimited Input and xargs Compatibility in Python CLIs",{"path":2656,"title":2657},"\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":2659,"title":2660},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Freading-piped-input-in-python-clis","Reading Piped Input in Python CLIs",{"path":2662,"title":2663},"\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":2665,"title":2666},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fdownloading-files-with-progress-in-python","Downloading Files with Progress in Python CLIs",{"path":2668,"title":2669},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis","Calling HTTP APIs from Python CLIs",{"path":2671,"title":2672},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fmocking-http-in-cli-tests-with-respx","Mocking HTTP in Python CLI Tests with respx",{"path":2674,"title":2675},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Foauth-device-flow-login-for-clis","OAuth Device Flow Login for Python CLIs",{"path":2677,"title":2678},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fpaginating-api-results-in-a-cli","Paginating API Results in a Python CLI",{"path":2680,"title":2681},"\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":2683,"title":2684},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fuploading-files-with-multipart-and-progress","Uploading Files with Multipart and Progress in a Python CLI",{"path":2686,"title":2687},"\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":2689,"title":2690},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis","Concurrency and Async in Python CLIs",{"path":2692,"title":2693},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Fmultiprocessing-for-cpu-bound-cli-tasks","Multiprocessing for CPU-Bound CLI Tasks",{"path":2695,"title":2696},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Fparallelising-cli-work-with-thread-pools","Parallelising CLI Work with Thread Pools",{"path":2698,"title":2699},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Frate-limiting-concurrent-requests-in-clis","Rate-Limiting Concurrent Requests in Python CLIs",{"path":2701,"title":2702},"\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":2704,"title":2705},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Fshowing-progress-for-concurrent-tasks","Showing Progress for Concurrent Tasks in a Python CLI",{"path":2707,"title":2708},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Fstructured-concurrency-with-taskgroups-in-clis","Structured Concurrency with TaskGroups in Python CLIs",{"path":2710,"title":2711},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fcross-platform-paths-with-pathlib","Cross-Platform Paths with pathlib in CLIs",{"path":2713,"title":2714},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Ffile-locking-for-concurrent-cli-runs","File Locking for Concurrent CLI Runs in Python",{"path":2716,"title":2717},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fhandling-file-permissions-and-umask-in-clis","Handling File Permissions and umask in Python CLIs",{"path":2719,"title":2720},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes","Filesystem Paths and Atomic Writes for CLIs",{"path":2722,"title":2723},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fsafe-temporary-files-and-directories","Safe Temporary Files and Directories in CLIs",{"path":2725,"title":2726},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fstoring-app-data-with-platformdirs","Storing CLI App Data with platformdirs",{"path":2728,"title":2729},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fwalking-directory-trees-with-ignore-rules","Walking Directory Trees with Ignore Rules in a Python CLI",{"path":2731,"title":2732},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fwriting-files-atomically-in-python-clis","Writing Files Atomically in Python CLIs",{"path":2734,"title":2735},"\u002Fcli-runtime-systems-integration","CLI Runtime & Systems Integration for Python",{"path":2737,"title":2738},"\u002Fcli-runtime-systems-integration\u002Flocal-state-and-sqlite-in-python-clis\u002Fcaching-http-responses-on-disk-in-a-cli","Caching HTTP Responses on Disk in a Python CLI",{"path":2740,"title":2741},"\u002Fcli-runtime-systems-integration\u002Flocal-state-and-sqlite-in-python-clis","Local State and SQLite in Python CLIs",{"path":2743,"title":2744},"\u002Fcli-runtime-systems-integration\u002Flocal-state-and-sqlite-in-python-clis\u002Fmigrating-a-cli-sqlite-schema","Migrating a CLI’s SQLite Schema Between Releases",{"path":2746,"title":2747},"\u002Fcli-runtime-systems-integration\u002Flocal-state-and-sqlite-in-python-clis\u002Frecording-and-querying-cli-run-history","Recording and Querying CLI Run History in SQLite",{"path":2749,"title":2750},"\u002Fcli-runtime-systems-integration\u002Flocal-state-and-sqlite-in-python-clis\u002Fstoring-cli-state-in-sqlite","Storing CLI State in SQLite with a Small Repository Class",{"path":2752,"title":2753},"\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":2755,"title":2756},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Fhandling-sigterm-and-graceful-shutdown","Handling SIGTERM and Graceful Shutdown in CLIs",{"path":2758,"title":2759},"\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":2761,"title":2762},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis","Long-Running and Watch-Mode Python CLIs",{"path":2764,"title":2765},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Freloading-config-on-sighup","Reloading Configuration on SIGHUP in a Python CLI",{"path":2767,"title":2768},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Frunning-a-cli-as-a-systemd-service","Running a Python CLI as a systemd Service",{"path":2770,"title":2771},"\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":2773,"title":2774},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Fsending-cli-logs-to-journald-and-syslog","Sending Python CLI Logs to journald and syslog",{"path":2776,"title":2777},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Favoiding-shell-injection-in-python-clis","Avoiding Shell Injection in Python CLIs",{"path":2779,"title":2780},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fcalling-external-commands-safely-with-subprocess","Calling External Commands Safely with subprocess",{"path":2782,"title":2783},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fhandling-subprocess-timeouts-and-exit-codes","Handling Subprocess Timeouts and Exit Codes",{"path":2785,"title":2786},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis","Running Subprocesses from Python CLIs",{"path":2788,"title":2789},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Flaunching-the-users-editor-from-a-cli","Launching the User’s Editor from a Python CLI",{"path":2791,"title":2792},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fpiping-between-subprocesses-in-python","Piping Between Subprocesses in Python Without a Shell",{"path":2794,"title":2795},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fstreaming-subprocess-output-in-real-time","Streaming Subprocess Output in Real Time",{"path":2797,"title":2798},"\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":2800,"title":2801},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis","Secrets and Credentials in Python CLIs",{"path":2803,"title":2804},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fprompting-for-passwords-securely","Prompting for Passwords Securely in Python CLIs",{"path":2806,"title":2807},"\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":2809,"title":2810},"\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":2812,"title":2813},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Frefreshing-expired-tokens-automatically","Refreshing Expired Tokens Automatically in a Python CLI",{"path":2815,"title":2816},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fstoring-tokens-with-keyring","Storing CLI Tokens Securely with keyring",{"path":2818,"title":2819},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fsupporting-multiple-profiles-and-accounts","Supporting Multiple Profiles and Accounts in CLIs",{"path":2821,"title":2822},"\u002Fcli-runtime-systems-integration\u002Fupdate-checks-and-self-updating-clis\u002Fchecking-pypi-for-a-newer-version","Checking PyPI for a Newer Version of Your Python CLI",{"path":2824,"title":2825},"\u002Fcli-runtime-systems-integration\u002Fupdate-checks-and-self-updating-clis","Update Checks, Upgrade Commands and Telemetry for Python CLIs",{"path":2827,"title":2828},"\u002Fcli-runtime-systems-integration\u002Fupdate-checks-and-self-updating-clis\u002Fopt-in-usage-telemetry-for-python-clis","Opt-In Usage Telemetry for Python CLIs Done Responsibly",{"path":2830,"title":2831},"\u002Fcli-runtime-systems-integration\u002Fupdate-checks-and-self-updating-clis\u002Fself-upgrading-a-cli-installed-with-pipx-or-uv","Self-Upgrading a Python CLI Installed with pipx or uv",{"path":2833,"title":2834},"\u002Fcli-runtime-systems-integration\u002Fupdate-checks-and-self-updating-clis\u002Fshowing-non-blocking-update-notices","Showing Non-Blocking Update Notices in a Python CLI",{"path":2836,"title":2837},"\u002F","Python CLI Toolcraft",{"path":2839,"title":2840},"\u002Fmodern-python-cli-frameworks-architecture\u002Falternative-python-cli-frameworks\u002Fbuilding-a-cli-with-cleo","Building a Python CLI with Cleo Command Classes",{"path":2842,"title":2843},"\u002Fmodern-python-cli-frameworks-architecture\u002Falternative-python-cli-frameworks\u002Fbuilding-a-cli-with-cyclopts","Building a Type-Hinted Python CLI with Cyclopts",{"path":2845,"title":2846},"\u002Fmodern-python-cli-frameworks-architecture\u002Falternative-python-cli-frameworks","Beyond Click and Typer: Alternative Python CLI Frameworks",{"path":2848,"title":2849},"\u002Fmodern-python-cli-frameworks-architecture\u002Falternative-python-cli-frameworks\u002Fquick-clis-from-functions-with-python-fire","Quick CLIs from Functions with Python Fire",{"path":2851,"title":2852},"\u002Fmodern-python-cli-frameworks-architecture\u002Falternative-python-cli-frameworks\u002Fusage-string-driven-clis-with-docopt-ng","Usage-String Driven Python CLIs with docopt-ng",{"path":2854,"title":2855},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Favoiding-import-time-side-effects","Avoiding Import-Time Side Effects in a Python CLI",{"path":2857,"title":2858},"\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":2860,"title":2861},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Fguarding-startup-with-import-tests","Guarding CLI Startup with Import Tests",{"path":2863,"title":2864},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading","CLI Startup Performance and Lazy Loading",{"path":2866,"title":2867},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Flazy-loading-subcommands-for-faster-startup","Lazy Loading Subcommands for Faster Startup",{"path":2869,"title":2870},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Fprofiling-python-cli-startup-time","Profiling Python CLI Startup Time",{"path":2872,"title":2873},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Freducing-cli-dependency-weight","Reducing CLI Dependency Weight",{"path":2875,"title":2876},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fargparse-subparsers-for-subcommands","argparse Subparsers for Subcommands",{"path":2878,"title":2879},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fargparse-vs-click-vs-typer-comparison","argparse vs Click vs Typer Compared",{"path":2881,"title":2882},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fargument-groups-and-help-formatting-in-argparse","Argument Groups and Help Formatting in argparse",{"path":2884,"title":2885},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse","Command-Line Parsing with argparse",{"path":2887,"title":2888},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fmigrating-from-argparse-to-typer","Migrating from argparse to Typer",{"path":2890,"title":2891},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fmutually-exclusive-options-in-argparse","Mutually Exclusive Options in argparse",{"path":2893,"title":2894},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Freading-arguments-from-files-with-fromfile-prefix-chars","Reading Arguments from Files with argparse’s fromfile_prefix_chars",{"path":2896,"title":2897},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fwriting-custom-argparse-actions","Writing Custom argparse Actions in Python",{"path":2899,"title":2900},"\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":2902,"title":2903},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions\u002Fdesigning-idempotent-commands","Designing Idempotent Commands in a Python CLI",{"path":2905,"title":2906},"\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":2908,"title":2909},"\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":2911,"title":2912},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions","Designing CLI Interfaces and Conventions in Python",{"path":2914,"title":2915},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions\u002Fnaming-commands-and-flags-consistently","Naming Commands and Flags Consistently in Python CLIs",{"path":2917,"title":2918},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions\u002Fpositional-arguments-vs-options","Positional Arguments vs Options: Designing a CLI Signature",{"path":2920,"title":2921},"\u002Fmodern-python-cli-frameworks-architecture","Python CLI Frameworks and Architecture",{"path":2923,"title":2924},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fdiscovering-plugins-with-entry-points","Discovering Plugins with Entry Points in Python CLIs",{"path":2926,"title":2927},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fhook-based-plugins-with-pluggy","Hook-Based Plugins for Python CLIs with pluggy",{"path":2929,"title":2930},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis","Plugin Architectures for Extensible CLIs",{"path":2932,"title":2933},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fisolating-plugin-failures","Isolating Plugin Failures in an Extensible Python CLI",{"path":2935,"title":2936},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Ftesting-plugins-against-the-host-cli","Testing Plugins Against the Host CLI",{"path":2938,"title":2939},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fversioning-a-plugin-api","Versioning a Plugin API for a Python CLI",{"path":2941,"title":2942},"\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":2944,"title":2945},"\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":2947,"title":2948},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fdependency-injection-patterns-for-cli-commands","Dependency Injection Patterns for CLI Commands",{"path":2950,"title":2951},"\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":2953,"title":2954},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis","Structuring Multi-Command Python CLIs",{"path":2956,"title":2957},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Foffering-a-python-api-alongside-your-cli","Offering a Python API Alongside Your CLI",{"path":2959,"title":2960},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fregistering-commands-from-modules-automatically","Registering CLI Commands from Modules Automatically",{"path":2962,"title":2963},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fsharing-common-options-across-commands","Sharing Common Options Across Python CLI Commands",{"path":2965,"title":2966},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fsharing-state-with-click-context-objects","Sharing State with Click Context Objects",{"path":2968,"title":2969},"\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":2971,"title":2972},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications","Testing Python CLI Applications",{"path":2974,"title":2975},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fmeasuring-cli-test-coverage","Measuring CLI Test Coverage",{"path":2977,"title":2978},"\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":2980,"title":2981},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fproperty-based-testing-cli-arguments-with-hypothesis","Property-Based Testing CLI Arguments with Hypothesis",{"path":2983,"title":2984},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fsnapshot-testing-cli-output","Snapshot Testing CLI Output",{"path":2986,"title":2987},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Ftesting-click-commands-with-clirunner","Testing Click Commands with CliRunner",{"path":2989,"title":2990},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Ftesting-commands-that-call-subprocesses","Testing Python CLI Commands That Call Subprocesses",{"path":2992,"title":2993},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Ftesting-interactive-prompts-and-stdin","Testing Interactive Prompts and stdin",{"path":2995,"title":2996},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Ftranscript-tests-for-cli-commands","Transcript Tests for Python CLI Commands",{"path":2998,"title":2999},"\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":3001,"title":3002},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fbuilding-dynamic-commands-in-click","Building Dynamic Commands in Click",{"path":3004,"title":3005},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fchoices-and-enums-in-typer-and-click","Choices and Enums in Typer and Click Options",{"path":3007,"title":3008},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fclick-option-callbacks-and-eager-options","Click Option Callbacks and Eager Options Explained",{"path":3010,"title":3011},"\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":3013,"title":3014},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each","Typer vs Click: When to Use Each",{"path":3016,"title":3017},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Frich-markup-and-help-panels-in-typer","Rich Markup and Help Panels in Typer",{"path":3019,"title":3020},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Ftyper-callback-functions-explained","Typer callback functions explained",{"path":3022,"title":3023},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fusing-annotated-options-in-typer","Using Annotated Options in Typer",{"path":3025,"title":3026},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Fautomating-releases-from-git-tags","Automating Python CLI Releases from Git Tags",{"path":3028,"title":3029},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Fcaching-uv-dependencies-in-ci","Caching uv Dependencies in CI for Python CLIs",{"path":3031,"title":3032},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis","CI\u002FCD Pipelines for Python CLIs",{"path":3034,"title":3035},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Fpublishing-a-cli-docker-image-from-ci","Publishing a Python CLI as a Docker Image from CI",{"path":3037,"title":3038},"\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":3040,"title":3041},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Frunning-cli-tests-on-windows-and-macos-runners","Running Python CLI Tests on Windows and macOS Runners",{"path":3043,"title":3044},"\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":3046,"title":3047},"\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":3049,"title":3050},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fbuilding-a-cookiecutter-template-for-typer-clis","Building a Cookiecutter Template for Typer CLIs",{"path":3052,"title":3053},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fcopier-vs-cookiecutter-for-cli-templates","Copier vs Cookiecutter for CLI Templates",{"path":3055,"title":3056},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter","CLI Project Scaffolding with Cookiecutter",{"path":3058,"title":3059},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fpost-generation-hooks-in-cli-templates","Post-Generation Hooks in Python CLI Templates",{"path":3061,"title":3062},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Ftemplate-variables-and-conditional-files","Template Variables and Conditional Files in CLI Templates",{"path":3064,"title":3065},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Ftesting-a-project-template-with-pytest","Testing a CLI Project Template with pytest",{"path":3067,"title":3068},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fupdating-generated-projects-with-copier-update","Updating Generated CLI Projects with copier update",{"path":3070,"title":3071},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fbuilding-cross-platform-release-binaries-in-ci","Building Cross-Platform Release Binaries in CI",{"path":3073,"title":3074},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fbundling-a-python-cli-with-pyinstaller","Bundling a Python CLI with PyInstaller",{"path":3076,"title":3077},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fcode-signing-and-notarizing-cli-binaries","Code Signing and Notarizing Python CLI Binaries",{"path":3079,"title":3080},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fhomebrew-and-scoop-packaging-for-python-clis","Homebrew and Scoop Packaging for Python CLIs",{"path":3082,"title":3083},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries","Distributing CLIs as Standalone Binaries",{"path":3085,"title":3086},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fnuitka-vs-pyinstaller-for-python-clis","Nuitka vs PyInstaller for Python CLI Binaries",{"path":3088,"title":3089},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Freducing-pyinstaller-binary-size","Reducing the Size of a PyInstaller CLI Binary",{"path":3091,"title":3092},"\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":3094,"title":3095},"\u002Fproject-setup-dependency-management","Project Setup & Dependency Management",{"path":3097,"title":3098},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code\u002Fconfiguring-ruff-for-a-cli-project","Configuring Ruff for a Python CLI Project",{"path":3100,"title":3101},"\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":3103,"title":3104},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code\u002Ffinding-unused-code-and-dependencies-with-vulture-and-deptry","Finding Unused Code and Dependencies with vulture and deptry",{"path":3106,"title":3107},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code","Linting and Type-Checking Python CLI Code",{"path":3109,"title":3110},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code\u002Frunning-pyright-in-strict-mode-on-a-cli","Running Pyright in Strict Mode on a Python CLI",{"path":3112,"title":3113},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code\u002Frunning-ruff-and-mypy-in-ci-with-annotations","Running Ruff and mypy in CI with Inline Annotations",{"path":3115,"title":3116},"\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":3118,"title":3119},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fautomating-changelogs-with-conventional-commits","Automating Changelogs with Conventional Commits",{"path":3121,"title":3122},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fbumping-versions-consistently-across-a-cli-project","Bumping Versions Consistently Across a Python CLI Project",{"path":3124,"title":3125},"\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":3127,"title":3128},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fexposing-version-info-and-build-metadata","Exposing Version Info and Build Metadata",{"path":3130,"title":3131},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs","Managing CLI Versioning & Changelogs",{"path":3133,"title":3134},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fsemantic-versioning-policy-for-cli-tools","A Semantic Versioning Policy for CLI Tools",{"path":3136,"title":3137},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fshipping-pre-releases-and-release-candidates","Shipping Pre-Releases and Release Candidates of a Python CLI",{"path":3139,"title":3140},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fbuilding-wheels-and-sdists-for-python-clis","Building Wheels and sdists for Python CLIs",{"path":3142,"title":3143},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fbundling-data-files-with-importlib-resources","Bundling Data Files with importlib.resources in CLIs",{"path":3145,"title":3146},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fchoosing-a-build-backend-for-a-python-cli","Choosing a Build Backend for a Python CLI",{"path":3148,"title":3149},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution","Packaging Python CLIs for Distribution",{"path":3151,"title":3152},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Finstalling-and-distributing-clis-with-pipx","Installing and Distributing CLIs with pipx",{"path":3154,"title":3155},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Foptional-dependencies-and-extras-for-clis","Optional Dependencies and Extras for Python CLIs",{"path":3157,"title":3158},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fpublishing-a-python-cli-to-pypi","Publishing a Python CLI to PyPI",{"path":3160,"title":3161},"\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":3163,"title":3164},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fdynamic-versioning-with-poetry-plugins","Dynamic Versioning for a Poetry CLI from Git Tags",{"path":3166,"title":3167},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development","Poetry Workflows for CLI Development",{"path":3169,"title":3170},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fmanaging-poetry-lock-files-for-cli-tools","Managing Poetry Lock Files for CLI Tools",{"path":3172,"title":3173},"\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":3175,"title":3176},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fpoetry-dependency-groups-for-cli-tooling","Poetry Dependency Groups for CLI Tooling",{"path":3178,"title":3179},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fpoetry-entry-points-and-scripts-for-clis","Poetry Entry Points and Scripts for CLIs",{"path":3181,"title":3182},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fpublishing-a-cli-with-poetry","Building and Publishing a Python CLI with Poetry",{"path":3184,"title":3185},"\u002Fproject-setup-dependency-management\u002Fpre-commit-hooks-for-cli-projects","Pre-commit Hooks for CLI Projects",{"path":3187,"title":3188},"\u002Fproject-setup-dependency-management\u002Fpre-commit-hooks-for-cli-projects\u002Fkeeping-hook-versions-current-with-autoupdate","Keeping pre-commit Hook Versions Current with autoupdate",{"path":3190,"title":3191},"\u002Fproject-setup-dependency-management\u002Fpre-commit-hooks-for-cli-projects\u002Frunning-pre-commit-in-ci","Running pre-commit in CI for a Python CLI Repository",{"path":3193,"title":3194},"\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":3196,"title":3197},"\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":3199,"title":3200},"\u002Fproject-setup-dependency-management\u002Fpre-commit-hooks-for-cli-projects\u002Fspeeding-up-slow-pre-commit-hooks","Speeding Up Slow pre-commit Hooks in a CLI Repository",{"path":3202,"title":3203},"\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":3205,"title":3206},"\u002Fproject-setup-dependency-management\u002Fsecuring-a-python-cli-supply-chain\u002Fauditing-dependencies-with-pip-audit","Auditing a Python CLI’s Dependencies with pip-audit",{"path":3208,"title":3209},"\u002Fproject-setup-dependency-management\u002Fsecuring-a-python-cli-supply-chain\u002Fgenerating-an-sbom-for-a-python-cli","Generating an SBOM for a Python CLI Release",{"path":3211,"title":3212},"\u002Fproject-setup-dependency-management\u002Fsecuring-a-python-cli-supply-chain","Securing the Supply Chain of a Python CLI",{"path":3214,"title":3215},"\u002Fproject-setup-dependency-management\u002Fsecuring-a-python-cli-supply-chain\u002Fpinning-dependencies-with-hashes","Pinning a Python CLI’s Dependencies with Hashes",{"path":3217,"title":3218},"\u002Fproject-setup-dependency-management\u002Fsecuring-a-python-cli-supply-chain\u002Fpublishing-attestations-and-verifying-releases","Publishing Attestations and Verifying Python CLI Releases",{"path":3220,"title":3221},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management\u002Fbuilding-and-publishing-a-cli-with-uv","Building and Publishing a Python CLI with uv",{"path":3223,"title":3224},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management","uv for Python CLI Dependency Management",{"path":3226,"title":3227},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management\u002Flocking-and-syncing-cli-dependencies-with-uv","Locking and Syncing a Python CLI’s Dependencies with uv",{"path":3229,"title":3230},"\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":3232,"title":3233},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management\u002Fusing-private-package-indexes-with-uv","Using Private Package Indexes with uv for Internal CLIs",{"path":3235,"title":3236},"\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":3238,"title":3239},"\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":3241,"title":3242},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management\u002Fuv-workspaces-for-multi-package-clis","uv Workspaces for Multi-Package Python CLIs",{"path":3244,"title":3245},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fdebugging-wrong-python-and-wrong-venv-problems","Debugging Wrong-Python and Wrong-Venv Problems in CLIs",{"path":3247,"title":3248},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fexternally-managed-environments-and-pep-668","PEP 668 and Python CLIs: the externally-managed-environment Error",{"path":3250,"title":3251},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices","Python CLI Env Isolation Best Practices",{"path":3253,"title":3254},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fisolating-cli-tools-from-project-dependencies","Isolating CLI Tools from Your Project’s Dependencies",{"path":3256,"title":3257},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fmanaging-virtual-environments-for-cross-platform-clis","Managing Python CLI Virtual Environments",{"path":3259,"title":3260},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fpinning-the-python-version-for-a-cli","Pinning the Python Version for a CLI",{"path":3262,"title":3263},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fsupporting-multiple-python-versions-with-nox","Supporting Multiple Python Versions with nox",1790967537214]