[{"data":1,"prerenderedAt":2436},["ShallowReactive",2],{"page-\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fpost-generation-hooks-in-cli-templates\u002F":3,"content-directory":1889},{"id":4,"title":5,"body":6,"date":1874,"description":1875,"difficulty":1876,"draft":1877,"extension":1878,"meta":1879,"navigation":155,"path":1880,"seo":1881,"stem":1882,"tags":1883,"updated":1874,"__hash__":1888},"content\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fpost-generation-hooks-in-cli-templates\u002Findex.md","Post-Generation Hooks in Python CLI Templates",{"type":7,"value":8,"toc":1854},"minimark",[9,33,38,55,59,63,79,90,94,97,449,467,471,474,1120,1125,1128,1139,1143,1146,1176,1180,1183,1231,1235,1265,1269,1276,1755,1758,1762,1765,1769,1773,1780,1784,1789,1793,1804,1808,1815,1819,1850],[10,11,12,13,17,18,21,22,27,28,32],"p",{},"A template can only do so much with Jinja. Some work has to happen as code: rejecting a command name that would shadow a system tool, deleting the Dockerfile when the user said they did not want one, creating the git repository and lockfile, and telling the user what to do next. Cookiecutter runs two optional Python scripts around generation for exactly this — ",[14,15,16],"code",{},"pre_gen_project.py"," before any files are written, and ",[14,19,20],{},"post_gen_project.py"," inside the freshly generated project. This guide covers what belongs in each hook for a CLI template, how to write them so they are fast and safe on other people's machines, and how to test them. It builds on ",[23,24,26],"a",{"href":25},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fbuilding-a-cookiecutter-template-for-typer-clis\u002F","building a cookiecutter template for Typer CLIs"," and belongs to the ",[23,29,31],{"href":30},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002F","CLI project scaffolding topic",".",[34,35,37],"h2",{"id":36},"prerequisites","Prerequisites",[39,40,41,52],"ul",{},[42,43,44,45,48,49,32],"li",{},"A working cookiecutter template with a ",[14,46,47],{},"hooks\u002F"," directory next to ",[14,50,51],{},"cookiecutter.json",[42,53,54],{},"git and uv available on the machines that will generate projects (the hooks check for them and degrade gracefully when they are missing).",[34,56,58],{"id":57},"when-hooks-run","When hooks run",[60,61],"inline-diagram",{"name":62},"hook-lifecycle",[10,64,65,66,69,70,73,74,78],{},"Cookiecutter collects answers, runs ",[14,67,68],{},"hooks\u002Fpre_gen_project.py"," (rendered through Jinja first, so it can read the answers), renders the template tree, then runs ",[14,71,72],{},"hooks\u002Fpost_gen_project.py"," with the ",[75,76,77],"strong",{},"current working directory set to the new project",". If either hook exits non-zero, cookiecutter stops and deletes whatever it generated, so a failed validation never leaves a half-made project behind.",[10,80,81,82,85,86,89],{},"Because hooks are rendered as Jinja templates, answers appear in them as literal values: ",[14,83,84],{},"\"{{ cookiecutter.command_name }}\""," inside a Python string becomes ",[14,87,88],{},"\"dh\""," before the script runs.",[34,91,93],{"id":92},"the-recipe-validating-answers-before-anything-is-written","The recipe: validating answers before anything is written",[10,95,96],{},"The pre-generation hook is the place to reject answers that would produce a broken project:",[98,99,104],"pre",{"className":100,"code":101,"language":102,"meta":103,"style":103},"language-python shiki shiki-themes github-light github-dark","# hooks\u002Fpre_gen_project.py\nimport keyword\nimport re\nimport shutil\nimport sys\n\npackage = \"{{ cookiecutter.package_name }}\"\ncommand = \"{{ cookiecutter.command_name }}\"\n\nerrors = []\nif not re.fullmatch(r\"[a-z][a-z0-9_]*\", package) or keyword.iskeyword(package):\n    errors.append(f\"package name {package!r} is not a valid Python identifier\")\nif not re.fullmatch(r\"[a-z][a-z0-9-]*\", command):\n    errors.append(f\"command {command!r} should be lowercase letters, digits and dashes\")\nif shutil.which(command):\n    errors.append(f\"command {command!r} already exists on this machine ({shutil.which(command)}); \"\n                  \"users would get the wrong program\")\n\nif errors:\n    for e in errors:\n        print(f\"error: {e}\", file=sys.stderr)\n    sys.exit(1)\n","python","",[14,105,106,115,126,134,142,150,157,183,202,207,218,253,283,306,330,338,368,376,381,389,403,438],{"__ignoreMap":103},[107,108,111],"span",{"class":109,"line":110},"line",1,[107,112,114],{"class":113},"sJ8bj","# hooks\u002Fpre_gen_project.py\n",[107,116,118,122],{"class":109,"line":117},2,[107,119,121],{"class":120},"szBVR","import",[107,123,125],{"class":124},"sVt8B"," keyword\n",[107,127,129,131],{"class":109,"line":128},3,[107,130,121],{"class":120},[107,132,133],{"class":124}," re\n",[107,135,137,139],{"class":109,"line":136},4,[107,138,121],{"class":120},[107,140,141],{"class":124}," shutil\n",[107,143,145,147],{"class":109,"line":144},5,[107,146,121],{"class":120},[107,148,149],{"class":124}," sys\n",[107,151,153],{"class":109,"line":152},6,[107,154,156],{"emptyLinePlaceholder":155},true,"\n",[107,158,160,163,166,170,174,177,180],{"class":109,"line":159},7,[107,161,162],{"class":124},"package ",[107,164,165],{"class":120},"=",[107,167,169],{"class":168},"sZZnC"," \"",[107,171,173],{"class":172},"sj4cs","{{",[107,175,176],{"class":168}," cookiecutter.package_name ",[107,178,179],{"class":172},"}}",[107,181,182],{"class":168},"\"\n",[107,184,186,189,191,193,195,198,200],{"class":109,"line":185},8,[107,187,188],{"class":124},"command ",[107,190,165],{"class":120},[107,192,169],{"class":168},[107,194,173],{"class":172},[107,196,197],{"class":168}," cookiecutter.command_name ",[107,199,179],{"class":172},[107,201,182],{"class":168},[107,203,205],{"class":109,"line":204},9,[107,206,156],{"emptyLinePlaceholder":155},[107,208,210,213,215],{"class":109,"line":209},10,[107,211,212],{"class":124},"errors ",[107,214,165],{"class":120},[107,216,217],{"class":124}," []\n",[107,219,221,224,227,230,233,236,239,242,244,247,250],{"class":109,"line":220},11,[107,222,223],{"class":120},"if",[107,225,226],{"class":120}," not",[107,228,229],{"class":124}," re.fullmatch(",[107,231,232],{"class":120},"r",[107,234,235],{"class":168},"\"",[107,237,238],{"class":172},"[a-z][a-z0-9_]",[107,240,241],{"class":120},"*",[107,243,235],{"class":168},[107,245,246],{"class":124},", package) ",[107,248,249],{"class":120},"or",[107,251,252],{"class":124}," keyword.iskeyword(package):\n",[107,254,256,259,262,265,268,271,274,277,280],{"class":109,"line":255},12,[107,257,258],{"class":124},"    errors.append(",[107,260,261],{"class":120},"f",[107,263,264],{"class":168},"\"package name ",[107,266,267],{"class":172},"{",[107,269,270],{"class":124},"package",[107,272,273],{"class":120},"!r",[107,275,276],{"class":172},"}",[107,278,279],{"class":168}," is not a valid Python identifier\"",[107,281,282],{"class":124},")\n",[107,284,286,288,290,292,294,296,299,301,303],{"class":109,"line":285},13,[107,287,223],{"class":120},[107,289,226],{"class":120},[107,291,229],{"class":124},[107,293,232],{"class":120},[107,295,235],{"class":168},[107,297,298],{"class":172},"[a-z][a-z0-9-]",[107,300,241],{"class":120},[107,302,235],{"class":168},[107,304,305],{"class":124},", command):\n",[107,307,309,311,313,316,318,321,323,325,328],{"class":109,"line":308},14,[107,310,258],{"class":124},[107,312,261],{"class":120},[107,314,315],{"class":168},"\"command ",[107,317,267],{"class":172},[107,319,320],{"class":124},"command",[107,322,273],{"class":120},[107,324,276],{"class":172},[107,326,327],{"class":168}," should be lowercase letters, digits and dashes\"",[107,329,282],{"class":124},[107,331,333,335],{"class":109,"line":332},15,[107,334,223],{"class":120},[107,336,337],{"class":124}," shutil.which(command):\n",[107,339,341,343,345,347,349,351,353,355,358,360,363,365],{"class":109,"line":340},16,[107,342,258],{"class":124},[107,344,261],{"class":120},[107,346,315],{"class":168},[107,348,267],{"class":172},[107,350,320],{"class":124},[107,352,273],{"class":120},[107,354,276],{"class":172},[107,356,357],{"class":168}," already exists on this machine (",[107,359,267],{"class":172},[107,361,362],{"class":124},"shutil.which(command)",[107,364,276],{"class":172},[107,366,367],{"class":168},"); \"\n",[107,369,371,374],{"class":109,"line":370},17,[107,372,373],{"class":168},"                  \"users would get the wrong program\"",[107,375,282],{"class":124},[107,377,379],{"class":109,"line":378},18,[107,380,156],{"emptyLinePlaceholder":155},[107,382,384,386],{"class":109,"line":383},19,[107,385,223],{"class":120},[107,387,388],{"class":124}," errors:\n",[107,390,392,395,398,401],{"class":109,"line":391},20,[107,393,394],{"class":120},"    for",[107,396,397],{"class":124}," e ",[107,399,400],{"class":120},"in",[107,402,388],{"class":124},[107,404,406,409,412,414,417,419,422,424,426,429,433,435],{"class":109,"line":405},21,[107,407,408],{"class":172},"        print",[107,410,411],{"class":124},"(",[107,413,261],{"class":120},[107,415,416],{"class":168},"\"error: ",[107,418,267],{"class":172},[107,420,421],{"class":124},"e",[107,423,276],{"class":172},[107,425,235],{"class":168},[107,427,428],{"class":124},", ",[107,430,432],{"class":431},"s4XuR","file",[107,434,165],{"class":120},[107,436,437],{"class":124},"sys.stderr)\n",[107,439,441,444,447],{"class":109,"line":440},22,[107,442,443],{"class":124},"    sys.exit(",[107,445,446],{"class":172},"1",[107,448,282],{"class":124},[10,450,451,452,428,455,458,459,462,463,466],{},"The shadowing check is specific to CLI templates and surprisingly valuable: a tool named ",[14,453,454],{},"test",[14,456,457],{},"deploy"," or ",[14,460,461],{},"sync"," collides with existing commands on many machines, and the resulting confusion (\"why does ",[14,464,465],{},"test --help"," print nothing?\") is miserable to debug later.",[34,468,470],{"id":469},"the-recipe-finishing-the-project-after-rendering","The recipe: finishing the project after rendering",[10,472,473],{},"The post-generation hook handles everything that cannot be expressed as a file: removing optional parts, initialising version control, locking dependencies and printing next steps.",[98,475,477],{"className":100,"code":476,"language":102,"meta":103,"style":103},"# hooks\u002Fpost_gen_project.py\nimport shutil\nimport subprocess\nimport sys\nfrom pathlib import Path\n\nINCLUDE_DOCKER = \"{{ cookiecutter.include_docker }}\" == \"yes\"\nPROJECT = \"{{ cookiecutter.project_slug }}\"\nCOMMAND = \"{{ cookiecutter.command_name }}\"\n\n\ndef remove(*paths: str) -> None:\n    for p in map(Path, paths):\n        if p.is_dir():\n            shutil.rmtree(p)\n        elif p.exists():\n            p.unlink()\n\n\ndef run(*cmd: str) -> bool:\n    \"\"\"Run a helper command; report and continue if it is missing or fails.\"\"\"\n    if shutil.which(cmd[0]) is None:\n        print(f\"note: {cmd[0]} not found; skipped: {' '.join(cmd)}\", file=sys.stderr)\n        return False\n    result = subprocess.run(cmd, capture_output=True, text=True)\n    if result.returncode != 0:\n        print(f\"note: '{' '.join(cmd)}' failed:\\n{result.stderr.strip()}\", file=sys.stderr)\n        return False\n    return True\n\n\nif not INCLUDE_DOCKER:\n    remove(\"Dockerfile\", \".dockerignore\")\n\nlocked = run(\"uv\", \"lock\")\nif run(\"git\", \"init\", \"-q\", \"-b\", \"main\"):\n    run(\"git\", \"add\", \"-A\")\n    run(\"git\", \"commit\", \"-q\", \"-m\", f\"Initial {PROJECT} from template\")\n\nprint(f\"\"\"\nCreated {PROJECT}. Next steps:\n\n  cd {PROJECT}\n  {\"uv sync\" if locked else \"uv lock && uv sync\"}\n  uv run {COMMAND} --help\n  uv run pytest\n\"\"\")\n",[14,478,479,484,490,497,503,516,520,545,563,580,584,588,616,631,639,644,652,657,661,665,688,693,715,762,771,801,817,858,865,874,879,884,896,912,917,938,971,991,1027,1032,1045,1056,1061,1070,1094,1106,1112],{"__ignoreMap":103},[107,480,481],{"class":109,"line":110},[107,482,483],{"class":113},"# hooks\u002Fpost_gen_project.py\n",[107,485,486,488],{"class":109,"line":117},[107,487,121],{"class":120},[107,489,141],{"class":124},[107,491,492,494],{"class":109,"line":128},[107,493,121],{"class":120},[107,495,496],{"class":124}," subprocess\n",[107,498,499,501],{"class":109,"line":136},[107,500,121],{"class":120},[107,502,149],{"class":124},[107,504,505,508,511,513],{"class":109,"line":144},[107,506,507],{"class":120},"from",[107,509,510],{"class":124}," pathlib ",[107,512,121],{"class":120},[107,514,515],{"class":124}," Path\n",[107,517,518],{"class":109,"line":152},[107,519,156],{"emptyLinePlaceholder":155},[107,521,522,525,528,530,532,535,537,539,542],{"class":109,"line":159},[107,523,524],{"class":172},"INCLUDE_DOCKER",[107,526,527],{"class":120}," =",[107,529,169],{"class":168},[107,531,173],{"class":172},[107,533,534],{"class":168}," cookiecutter.include_docker ",[107,536,179],{"class":172},[107,538,235],{"class":168},[107,540,541],{"class":120}," ==",[107,543,544],{"class":168}," \"yes\"\n",[107,546,547,550,552,554,556,559,561],{"class":109,"line":185},[107,548,549],{"class":172},"PROJECT",[107,551,527],{"class":120},[107,553,169],{"class":168},[107,555,173],{"class":172},[107,557,558],{"class":168}," cookiecutter.project_slug ",[107,560,179],{"class":172},[107,562,182],{"class":168},[107,564,565,568,570,572,574,576,578],{"class":109,"line":204},[107,566,567],{"class":172},"COMMAND",[107,569,527],{"class":120},[107,571,169],{"class":168},[107,573,173],{"class":172},[107,575,197],{"class":168},[107,577,179],{"class":172},[107,579,182],{"class":168},[107,581,582],{"class":109,"line":209},[107,583,156],{"emptyLinePlaceholder":155},[107,585,586],{"class":109,"line":220},[107,587,156],{"emptyLinePlaceholder":155},[107,589,590,593,597,599,601,604,607,610,613],{"class":109,"line":255},[107,591,592],{"class":120},"def",[107,594,596],{"class":595},"sScJk"," remove",[107,598,411],{"class":124},[107,600,241],{"class":120},[107,602,603],{"class":124},"paths: ",[107,605,606],{"class":172},"str",[107,608,609],{"class":124},") -> ",[107,611,612],{"class":172},"None",[107,614,615],{"class":124},":\n",[107,617,618,620,623,625,628],{"class":109,"line":285},[107,619,394],{"class":120},[107,621,622],{"class":124}," p ",[107,624,400],{"class":120},[107,626,627],{"class":172}," map",[107,629,630],{"class":124},"(Path, paths):\n",[107,632,633,636],{"class":109,"line":308},[107,634,635],{"class":120},"        if",[107,637,638],{"class":124}," p.is_dir():\n",[107,640,641],{"class":109,"line":332},[107,642,643],{"class":124},"            shutil.rmtree(p)\n",[107,645,646,649],{"class":109,"line":340},[107,647,648],{"class":120},"        elif",[107,650,651],{"class":124}," p.exists():\n",[107,653,654],{"class":109,"line":370},[107,655,656],{"class":124},"            p.unlink()\n",[107,658,659],{"class":109,"line":378},[107,660,156],{"emptyLinePlaceholder":155},[107,662,663],{"class":109,"line":383},[107,664,156],{"emptyLinePlaceholder":155},[107,666,667,669,672,674,676,679,681,683,686],{"class":109,"line":391},[107,668,592],{"class":120},[107,670,671],{"class":595}," run",[107,673,411],{"class":124},[107,675,241],{"class":120},[107,677,678],{"class":124},"cmd: ",[107,680,606],{"class":172},[107,682,609],{"class":124},[107,684,685],{"class":172},"bool",[107,687,615],{"class":124},[107,689,690],{"class":109,"line":405},[107,691,692],{"class":168},"    \"\"\"Run a helper command; report and continue if it is missing or fails.\"\"\"\n",[107,694,695,698,701,704,707,710,713],{"class":109,"line":440},[107,696,697],{"class":120},"    if",[107,699,700],{"class":124}," shutil.which(cmd[",[107,702,703],{"class":172},"0",[107,705,706],{"class":124},"]) ",[107,708,709],{"class":120},"is",[107,711,712],{"class":172}," None",[107,714,615],{"class":124},[107,716,718,720,722,724,727,729,732,734,737,739,742,744,747,750,752,754,756,758,760],{"class":109,"line":717},23,[107,719,408],{"class":172},[107,721,411],{"class":124},[107,723,261],{"class":120},[107,725,726],{"class":168},"\"note: ",[107,728,267],{"class":172},[107,730,731],{"class":124},"cmd[",[107,733,703],{"class":172},[107,735,736],{"class":124},"]",[107,738,276],{"class":172},[107,740,741],{"class":168}," not found; skipped: ",[107,743,267],{"class":172},[107,745,746],{"class":168},"' '",[107,748,749],{"class":124},".join(cmd)",[107,751,276],{"class":172},[107,753,235],{"class":168},[107,755,428],{"class":124},[107,757,432],{"class":431},[107,759,165],{"class":120},[107,761,437],{"class":124},[107,763,765,768],{"class":109,"line":764},24,[107,766,767],{"class":120},"        return",[107,769,770],{"class":172}," False\n",[107,772,774,777,779,782,785,787,790,792,795,797,799],{"class":109,"line":773},25,[107,775,776],{"class":124},"    result ",[107,778,165],{"class":120},[107,780,781],{"class":124}," subprocess.run(cmd, ",[107,783,784],{"class":431},"capture_output",[107,786,165],{"class":120},[107,788,789],{"class":172},"True",[107,791,428],{"class":124},[107,793,794],{"class":431},"text",[107,796,165],{"class":120},[107,798,789],{"class":172},[107,800,282],{"class":124},[107,802,804,806,809,812,815],{"class":109,"line":803},26,[107,805,697],{"class":120},[107,807,808],{"class":124}," result.returncode ",[107,810,811],{"class":120},"!=",[107,813,814],{"class":172}," 0",[107,816,615],{"class":124},[107,818,820,822,824,826,829,831,833,835,837,840,843,846,848,850,852,854,856],{"class":109,"line":819},27,[107,821,408],{"class":172},[107,823,411],{"class":124},[107,825,261],{"class":120},[107,827,828],{"class":168},"\"note: '",[107,830,267],{"class":172},[107,832,746],{"class":168},[107,834,749],{"class":124},[107,836,276],{"class":172},[107,838,839],{"class":168},"' failed:",[107,841,842],{"class":172},"\\n{",[107,844,845],{"class":124},"result.stderr.strip()",[107,847,276],{"class":172},[107,849,235],{"class":168},[107,851,428],{"class":124},[107,853,432],{"class":431},[107,855,165],{"class":120},[107,857,437],{"class":124},[107,859,861,863],{"class":109,"line":860},28,[107,862,767],{"class":120},[107,864,770],{"class":172},[107,866,868,871],{"class":109,"line":867},29,[107,869,870],{"class":120},"    return",[107,872,873],{"class":172}," True\n",[107,875,877],{"class":109,"line":876},30,[107,878,156],{"emptyLinePlaceholder":155},[107,880,882],{"class":109,"line":881},31,[107,883,156],{"emptyLinePlaceholder":155},[107,885,887,889,891,894],{"class":109,"line":886},32,[107,888,223],{"class":120},[107,890,226],{"class":120},[107,892,893],{"class":172}," INCLUDE_DOCKER",[107,895,615],{"class":124},[107,897,899,902,905,907,910],{"class":109,"line":898},33,[107,900,901],{"class":124},"    remove(",[107,903,904],{"class":168},"\"Dockerfile\"",[107,906,428],{"class":124},[107,908,909],{"class":168},"\".dockerignore\"",[107,911,282],{"class":124},[107,913,915],{"class":109,"line":914},34,[107,916,156],{"emptyLinePlaceholder":155},[107,918,920,923,925,928,931,933,936],{"class":109,"line":919},35,[107,921,922],{"class":124},"locked ",[107,924,165],{"class":120},[107,926,927],{"class":124}," run(",[107,929,930],{"class":168},"\"uv\"",[107,932,428],{"class":124},[107,934,935],{"class":168},"\"lock\"",[107,937,282],{"class":124},[107,939,941,943,945,948,950,953,955,958,960,963,965,968],{"class":109,"line":940},36,[107,942,223],{"class":120},[107,944,927],{"class":124},[107,946,947],{"class":168},"\"git\"",[107,949,428],{"class":124},[107,951,952],{"class":168},"\"init\"",[107,954,428],{"class":124},[107,956,957],{"class":168},"\"-q\"",[107,959,428],{"class":124},[107,961,962],{"class":168},"\"-b\"",[107,964,428],{"class":124},[107,966,967],{"class":168},"\"main\"",[107,969,970],{"class":124},"):\n",[107,972,974,977,979,981,984,986,989],{"class":109,"line":973},37,[107,975,976],{"class":124},"    run(",[107,978,947],{"class":168},[107,980,428],{"class":124},[107,982,983],{"class":168},"\"add\"",[107,985,428],{"class":124},[107,987,988],{"class":168},"\"-A\"",[107,990,282],{"class":124},[107,992,994,996,998,1000,1003,1005,1007,1009,1012,1014,1016,1019,1022,1025],{"class":109,"line":993},38,[107,995,976],{"class":124},[107,997,947],{"class":168},[107,999,428],{"class":124},[107,1001,1002],{"class":168},"\"commit\"",[107,1004,428],{"class":124},[107,1006,957],{"class":168},[107,1008,428],{"class":124},[107,1010,1011],{"class":168},"\"-m\"",[107,1013,428],{"class":124},[107,1015,261],{"class":120},[107,1017,1018],{"class":168},"\"Initial ",[107,1020,1021],{"class":172},"{PROJECT}",[107,1023,1024],{"class":168}," from template\"",[107,1026,282],{"class":124},[107,1028,1030],{"class":109,"line":1029},39,[107,1031,156],{"emptyLinePlaceholder":155},[107,1033,1035,1038,1040,1042],{"class":109,"line":1034},40,[107,1036,1037],{"class":172},"print",[107,1039,411],{"class":124},[107,1041,261],{"class":120},[107,1043,1044],{"class":168},"\"\"\"\n",[107,1046,1048,1051,1053],{"class":109,"line":1047},41,[107,1049,1050],{"class":168},"Created ",[107,1052,1021],{"class":172},[107,1054,1055],{"class":168},". Next steps:\n",[107,1057,1059],{"class":109,"line":1058},42,[107,1060,156],{"emptyLinePlaceholder":155},[107,1062,1064,1067],{"class":109,"line":1063},43,[107,1065,1066],{"class":168},"  cd ",[107,1068,1069],{"class":172},"{PROJECT}\n",[107,1071,1073,1076,1079,1082,1085,1088,1091],{"class":109,"line":1072},44,[107,1074,1075],{"class":172},"  {",[107,1077,1078],{"class":168},"\"uv sync\"",[107,1080,1081],{"class":120}," if",[107,1083,1084],{"class":124}," locked ",[107,1086,1087],{"class":120},"else",[107,1089,1090],{"class":168}," \"uv lock && uv sync\"",[107,1092,1093],{"class":172},"}\n",[107,1095,1097,1100,1103],{"class":109,"line":1096},45,[107,1098,1099],{"class":168},"  uv run ",[107,1101,1102],{"class":172},"{COMMAND}",[107,1104,1105],{"class":168}," --help\n",[107,1107,1109],{"class":109,"line":1108},46,[107,1110,1111],{"class":168},"  uv run pytest\n",[107,1113,1115,1118],{"class":109,"line":1114},47,[107,1116,1117],{"class":168},"\"\"\"",[107,1119,282],{"class":124},[1121,1122,1124],"h3",{"id":1123},"choosing-template-logic-or-a-hook","Choosing template logic or a hook",[60,1126],{"name":1127},"hook-conditional",[10,1129,1130,1131,1134,1135,1138],{},"Small optional differences — an extra dependency line, a conditional section in the README — read best as ",[14,1132,1133],{},"{% if %}"," blocks in the template. Whole optional files and directories are clearer to delete in the hook: a template tree with conditionally empty file names is hard to follow, whereas ",[14,1136,1137],{},"remove(\"Dockerfile\")"," says exactly what happens.",[1121,1140,1142],{"id":1141},"principles-for-hooks-on-other-peoples-machines","Principles for hooks on other people's machines",[60,1144],{"name":1145},"hook-tasks",[39,1147,1148,1154,1164,1170],{},[42,1149,1150,1153],{},[75,1151,1152],{},"Degrade, do not fail, on missing tools."," A developer without uv installed should still get a project, plus a note saying which step was skipped. Only validation failures in the pre hook should abort generation.",[42,1155,1156,1159,1160,1163],{},[75,1157,1158],{},"Stay local and fast."," ",[14,1161,1162],{},"uv lock"," downloads metadata, which is usually acceptable; anything slower, or anything that needs credentials — creating a GitHub repository, registering a PyPI name — belongs in documentation or a separate command the user chooses to run.",[42,1165,1166,1169],{},[75,1167,1168],{},"Use only the standard library."," Hooks run in cookiecutter's environment, not the new project's. Importing a third-party package in a hook fails for anyone who does not happen to have it installed.",[42,1171,1172,1175],{},[75,1173,1174],{},"Never touch anything outside the new directory."," The hook's working directory is the generated project; keep it there.",[34,1177,1179],{"id":1178},"debugging-hooks","Debugging hooks",[10,1181,1182],{},"Hook failures are confusing because the hook runs as a rendered copy of your script in a temporary location, and cookiecutter deletes the half-generated output when it fails. A few habits make them tractable:",[39,1184,1185,1194,1203,1217],{},[42,1186,1187,1193],{},[75,1188,1189,1190,32],{},"Run cookiecutter with ",[14,1191,1192],{},"--verbose"," It prints the rendered hook path and the command used to run it, so you can see exactly what executed.",[42,1195,1196,1159,1199,1202],{},[75,1197,1198],{},"Keep failed output while debugging.",[14,1200,1201],{},"--keep-project-on-failure"," leaves the generated directory in place after a post-hook failure, so you can inspect what was rendered and rerun the hook by hand inside it.",[42,1204,1205,1208,1209,1212,1213,1216],{},[75,1206,1207],{},"Check the rendered script first."," Most hook bugs are Jinja bugs: a variable that renders to an empty string, or a quote inside an answer that breaks the Python string it was substituted into. Rendering answers through Python literals — ",[14,1210,1211],{},"PROJECT = {{ cookiecutter.project_slug | tojson }}"," — avoids the quoting problem entirely, because ",[14,1214,1215],{},"tojson"," produces a valid Python string literal for any value.",[42,1218,1219,1222,1223,1226,1227,1230],{},[75,1220,1221],{},"Remember Windows."," Hooks run with the interpreter that runs cookiecutter, on whatever platform the user has. Use ",[14,1224,1225],{},"pathlib"," and ",[14,1228,1229],{},"subprocess"," argument lists rather than shell strings, so the same hook works in PowerShell and bash alike.",[34,1232,1234],{"id":1233},"ux-considerations","UX considerations",[39,1236,1237,1247,1253,1259],{},[42,1238,1239,1242,1243,1246],{},[75,1240,1241],{},"End with the next three commands."," The single most useful thing a post hook can do is tell the user how to run what they just created. Tailor it to what actually succeeded — as the ",[14,1244,1245],{},"locked"," flag does above.",[42,1248,1249,1252],{},[75,1250,1251],{},"Explain validation failures in the user's terms."," \"command 'test' already exists on this machine (\u002Fusr\u002Fbin\u002Ftest)\" explains the problem and implies the fix.",[42,1254,1255,1258],{},[75,1256,1257],{},"Make the initial commit meaningful."," A first commit containing exactly what the template produced makes it easy to see later which changes the team made on top.",[42,1260,1261,1264],{},[75,1262,1263],{},"Keep output short."," Notes about skipped steps on stderr, the next-steps block on stdout, nothing else.",[34,1266,1268],{"id":1267},"testing-the-behaviour","Testing the behaviour",[10,1270,1271,1272,1275],{},"Hooks run as part of ",[14,1273,1274],{},"cookiecutter(...)",", so the same generate-and-inspect tests from the template guide exercise them. Add cases for each branch:",[98,1277,1279],{"className":100,"code":1278,"language":102,"meta":103,"style":103},"# tests\u002Ftest_hooks.py\nimport shutil\nimport subprocess\nfrom pathlib import Path\n\nimport pytest\nfrom cookiecutter.exceptions import FailedHookException\nfrom cookiecutter.main import cookiecutter\n\nTEMPLATE = str(Path(__file__).parent.parent)\n\n\ndef generate(tmp_path, **context) -> Path:\n    return Path(cookiecutter(TEMPLATE, no_input=True, output_dir=str(tmp_path),\n                             extra_context=context))\n\n\ndef test_docker_files_removed_when_not_wanted(tmp_path):\n    project = generate(tmp_path, project_name=\"Alpha Tool\", include_docker=\"no\")\n    assert not (project \u002F \"Dockerfile\").exists()\n\n\ndef test_git_repository_and_lockfile_created(tmp_path):\n    if not (shutil.which(\"git\") and shutil.which(\"uv\")):\n        pytest.skip(\"needs git and uv\")\n    project = generate(tmp_path, project_name=\"Beta Tool\")\n    assert (project \u002F \"uv.lock\").exists()\n    log = subprocess.run([\"git\", \"log\", \"--oneline\"], cwd=project, capture_output=True, text=True)\n    assert \"Initial beta-tool from template\" in log.stdout\n\n\ndef test_shadowing_command_is_rejected(tmp_path):\n    with pytest.raises(FailedHookException):\n        generate(tmp_path, project_name=\"Gamma\", command_name=\"ls\")\n    assert list(tmp_path.iterdir()) == []            # nothing left behind\n\n\ndef test_invalid_package_name_is_rejected(tmp_path):\n    with pytest.raises(FailedHookException):\n        generate(tmp_path, project_name=\"Class\", package_name=\"class\")\n",[14,1280,1281,1286,1292,1298,1308,1312,1319,1331,1343,1347,1366,1370,1374,1390,1420,1430,1434,1438,1448,1478,1497,1501,1505,1514,1539,1549,1566,1579,1628,1641,1645,1649,1658,1666,1690,1709,1713,1717,1726,1732],{"__ignoreMap":103},[107,1282,1283],{"class":109,"line":110},[107,1284,1285],{"class":113},"# tests\u002Ftest_hooks.py\n",[107,1287,1288,1290],{"class":109,"line":117},[107,1289,121],{"class":120},[107,1291,141],{"class":124},[107,1293,1294,1296],{"class":109,"line":128},[107,1295,121],{"class":120},[107,1297,496],{"class":124},[107,1299,1300,1302,1304,1306],{"class":109,"line":136},[107,1301,507],{"class":120},[107,1303,510],{"class":124},[107,1305,121],{"class":120},[107,1307,515],{"class":124},[107,1309,1310],{"class":109,"line":144},[107,1311,156],{"emptyLinePlaceholder":155},[107,1313,1314,1316],{"class":109,"line":152},[107,1315,121],{"class":120},[107,1317,1318],{"class":124}," pytest\n",[107,1320,1321,1323,1326,1328],{"class":109,"line":159},[107,1322,507],{"class":120},[107,1324,1325],{"class":124}," cookiecutter.exceptions ",[107,1327,121],{"class":120},[107,1329,1330],{"class":124}," FailedHookException\n",[107,1332,1333,1335,1338,1340],{"class":109,"line":185},[107,1334,507],{"class":120},[107,1336,1337],{"class":124}," cookiecutter.main ",[107,1339,121],{"class":120},[107,1341,1342],{"class":124}," cookiecutter\n",[107,1344,1345],{"class":109,"line":204},[107,1346,156],{"emptyLinePlaceholder":155},[107,1348,1349,1352,1354,1357,1360,1363],{"class":109,"line":209},[107,1350,1351],{"class":172},"TEMPLATE",[107,1353,527],{"class":120},[107,1355,1356],{"class":172}," str",[107,1358,1359],{"class":124},"(Path(",[107,1361,1362],{"class":172},"__file__",[107,1364,1365],{"class":124},").parent.parent)\n",[107,1367,1368],{"class":109,"line":220},[107,1369,156],{"emptyLinePlaceholder":155},[107,1371,1372],{"class":109,"line":255},[107,1373,156],{"emptyLinePlaceholder":155},[107,1375,1376,1378,1381,1384,1387],{"class":109,"line":285},[107,1377,592],{"class":120},[107,1379,1380],{"class":595}," generate",[107,1382,1383],{"class":124},"(tmp_path, ",[107,1385,1386],{"class":120},"**",[107,1388,1389],{"class":124},"context) -> Path:\n",[107,1391,1392,1394,1397,1399,1401,1404,1406,1408,1410,1413,1415,1417],{"class":109,"line":308},[107,1393,870],{"class":120},[107,1395,1396],{"class":124}," Path(cookiecutter(",[107,1398,1351],{"class":172},[107,1400,428],{"class":124},[107,1402,1403],{"class":431},"no_input",[107,1405,165],{"class":120},[107,1407,789],{"class":172},[107,1409,428],{"class":124},[107,1411,1412],{"class":431},"output_dir",[107,1414,165],{"class":120},[107,1416,606],{"class":172},[107,1418,1419],{"class":124},"(tmp_path),\n",[107,1421,1422,1425,1427],{"class":109,"line":332},[107,1423,1424],{"class":431},"                             extra_context",[107,1426,165],{"class":120},[107,1428,1429],{"class":124},"context))\n",[107,1431,1432],{"class":109,"line":340},[107,1433,156],{"emptyLinePlaceholder":155},[107,1435,1436],{"class":109,"line":370},[107,1437,156],{"emptyLinePlaceholder":155},[107,1439,1440,1442,1445],{"class":109,"line":378},[107,1441,592],{"class":120},[107,1443,1444],{"class":595}," test_docker_files_removed_when_not_wanted",[107,1446,1447],{"class":124},"(tmp_path):\n",[107,1449,1450,1453,1455,1458,1461,1463,1466,1468,1471,1473,1476],{"class":109,"line":383},[107,1451,1452],{"class":124},"    project ",[107,1454,165],{"class":120},[107,1456,1457],{"class":124}," generate(tmp_path, ",[107,1459,1460],{"class":431},"project_name",[107,1462,165],{"class":120},[107,1464,1465],{"class":168},"\"Alpha Tool\"",[107,1467,428],{"class":124},[107,1469,1470],{"class":431},"include_docker",[107,1472,165],{"class":120},[107,1474,1475],{"class":168},"\"no\"",[107,1477,282],{"class":124},[107,1479,1480,1483,1485,1488,1491,1494],{"class":109,"line":391},[107,1481,1482],{"class":120},"    assert",[107,1484,226],{"class":120},[107,1486,1487],{"class":124}," (project ",[107,1489,1490],{"class":120},"\u002F",[107,1492,1493],{"class":168}," \"Dockerfile\"",[107,1495,1496],{"class":124},").exists()\n",[107,1498,1499],{"class":109,"line":405},[107,1500,156],{"emptyLinePlaceholder":155},[107,1502,1503],{"class":109,"line":440},[107,1504,156],{"emptyLinePlaceholder":155},[107,1506,1507,1509,1512],{"class":109,"line":717},[107,1508,592],{"class":120},[107,1510,1511],{"class":595}," test_git_repository_and_lockfile_created",[107,1513,1447],{"class":124},[107,1515,1516,1518,1520,1523,1525,1528,1531,1534,1536],{"class":109,"line":764},[107,1517,697],{"class":120},[107,1519,226],{"class":120},[107,1521,1522],{"class":124}," (shutil.which(",[107,1524,947],{"class":168},[107,1526,1527],{"class":124},") ",[107,1529,1530],{"class":120},"and",[107,1532,1533],{"class":124}," shutil.which(",[107,1535,930],{"class":168},[107,1537,1538],{"class":124},")):\n",[107,1540,1541,1544,1547],{"class":109,"line":773},[107,1542,1543],{"class":124},"        pytest.skip(",[107,1545,1546],{"class":168},"\"needs git and uv\"",[107,1548,282],{"class":124},[107,1550,1551,1553,1555,1557,1559,1561,1564],{"class":109,"line":803},[107,1552,1452],{"class":124},[107,1554,165],{"class":120},[107,1556,1457],{"class":124},[107,1558,1460],{"class":431},[107,1560,165],{"class":120},[107,1562,1563],{"class":168},"\"Beta Tool\"",[107,1565,282],{"class":124},[107,1567,1568,1570,1572,1574,1577],{"class":109,"line":819},[107,1569,1482],{"class":120},[107,1571,1487],{"class":124},[107,1573,1490],{"class":120},[107,1575,1576],{"class":168}," \"uv.lock\"",[107,1578,1496],{"class":124},[107,1580,1581,1584,1586,1589,1591,1593,1596,1598,1601,1604,1607,1609,1612,1614,1616,1618,1620,1622,1624,1626],{"class":109,"line":860},[107,1582,1583],{"class":124},"    log ",[107,1585,165],{"class":120},[107,1587,1588],{"class":124}," subprocess.run([",[107,1590,947],{"class":168},[107,1592,428],{"class":124},[107,1594,1595],{"class":168},"\"log\"",[107,1597,428],{"class":124},[107,1599,1600],{"class":168},"\"--oneline\"",[107,1602,1603],{"class":124},"], ",[107,1605,1606],{"class":431},"cwd",[107,1608,165],{"class":120},[107,1610,1611],{"class":124},"project, ",[107,1613,784],{"class":431},[107,1615,165],{"class":120},[107,1617,789],{"class":172},[107,1619,428],{"class":124},[107,1621,794],{"class":431},[107,1623,165],{"class":120},[107,1625,789],{"class":172},[107,1627,282],{"class":124},[107,1629,1630,1632,1635,1638],{"class":109,"line":867},[107,1631,1482],{"class":120},[107,1633,1634],{"class":168}," \"Initial beta-tool from template\"",[107,1636,1637],{"class":120}," in",[107,1639,1640],{"class":124}," log.stdout\n",[107,1642,1643],{"class":109,"line":876},[107,1644,156],{"emptyLinePlaceholder":155},[107,1646,1647],{"class":109,"line":881},[107,1648,156],{"emptyLinePlaceholder":155},[107,1650,1651,1653,1656],{"class":109,"line":886},[107,1652,592],{"class":120},[107,1654,1655],{"class":595}," test_shadowing_command_is_rejected",[107,1657,1447],{"class":124},[107,1659,1660,1663],{"class":109,"line":898},[107,1661,1662],{"class":120},"    with",[107,1664,1665],{"class":124}," pytest.raises(FailedHookException):\n",[107,1667,1668,1671,1673,1675,1678,1680,1683,1685,1688],{"class":109,"line":914},[107,1669,1670],{"class":124},"        generate(tmp_path, ",[107,1672,1460],{"class":431},[107,1674,165],{"class":120},[107,1676,1677],{"class":168},"\"Gamma\"",[107,1679,428],{"class":124},[107,1681,1682],{"class":431},"command_name",[107,1684,165],{"class":120},[107,1686,1687],{"class":168},"\"ls\"",[107,1689,282],{"class":124},[107,1691,1692,1694,1697,1700,1703,1706],{"class":109,"line":919},[107,1693,1482],{"class":120},[107,1695,1696],{"class":172}," list",[107,1698,1699],{"class":124},"(tmp_path.iterdir()) ",[107,1701,1702],{"class":120},"==",[107,1704,1705],{"class":124}," []            ",[107,1707,1708],{"class":113},"# nothing left behind\n",[107,1710,1711],{"class":109,"line":940},[107,1712,156],{"emptyLinePlaceholder":155},[107,1714,1715],{"class":109,"line":973},[107,1716,156],{"emptyLinePlaceholder":155},[107,1718,1719,1721,1724],{"class":109,"line":993},[107,1720,592],{"class":120},[107,1722,1723],{"class":595}," test_invalid_package_name_is_rejected",[107,1725,1447],{"class":124},[107,1727,1728,1730],{"class":109,"line":1029},[107,1729,1662],{"class":120},[107,1731,1665],{"class":124},[107,1733,1734,1736,1738,1740,1743,1745,1748,1750,1753],{"class":109,"line":1034},[107,1735,1670],{"class":124},[107,1737,1460],{"class":431},[107,1739,165],{"class":120},[107,1741,1742],{"class":168},"\"Class\"",[107,1744,428],{"class":124},[107,1746,1747],{"class":431},"package_name",[107,1749,165],{"class":120},[107,1751,1752],{"class":168},"\"class\"",[107,1754,282],{"class":124},[10,1756,1757],{},"The \"nothing left behind\" assertion verifies cookiecutter's cleanup on hook failure — the behaviour users rely on when they mistype an answer. Run these tests in the template's CI; hooks are exactly the part of a template that breaks silently when a tool changes its command-line flags.",[34,1759,1761],{"id":1760},"conclusion","Conclusion",[10,1763,1764],{},"Hooks are where a template stops being a pile of files and becomes a tool. Use the pre-generation hook to reject answers that would produce broken or confusing projects — invalid identifiers, commands that shadow existing programs — and the post-generation hook to remove unused files, lock dependencies, create the first commit and print the next steps. Keep hooks fast, local and standard-library-only, let them degrade gracefully when tools are missing, and test every branch by generating projects in pytest.",[34,1766,1768],{"id":1767},"frequently-asked-questions","Frequently asked questions",[1121,1770,1772],{"id":1771},"can-hooks-be-shell-scripts-instead-of-python","Can hooks be shell scripts instead of Python?",[10,1774,1775,1776,1779],{},"Yes — ",[14,1777,1778],{},"pre_gen_project.sh"," works on POSIX systems. Python hooks are the better choice for CLI templates because they run identically on Windows, macOS and Linux, and your template's users are Python developers anyway.",[1121,1781,1783],{"id":1782},"how-do-i-pass-data-from-the-pre-hook-to-the-post-hook","How do I pass data from the pre hook to the post hook?",[10,1785,1786,1787,32],{},"There is no direct channel. Anything both hooks need should be a cookiecutter variable, possibly a private one (prefixed with an underscore) computed from other answers in ",[14,1788,51],{},[1121,1790,1792],{"id":1791},"should-the-post-hook-run-the-tests","Should the post hook run the tests?",[10,1794,1795,1796,1799,1800,1803],{},"It can, but it slows generation and makes it fail for reasons unrelated to the template (a flaky network during ",[14,1797,1798],{},"uv sync","). Printing ",[14,1801,1802],{},"uv run pytest"," as a next step is usually better; the template's own CI already proves generated projects pass.",[1121,1805,1807],{"id":1806},"does-copier-have-the-same-hooks","Does Copier have the same hooks?",[10,1809,1810,1811,1814],{},"Copier calls them tasks, defined in ",[14,1812,1813],{},"copier.yml"," as commands run after copying, and adds migrations for template updates. The same principles apply: validate early, keep tasks local and fast, and test them.",[34,1816,1818],{"id":1817},"related","Related",[39,1820,1821,1827,1832,1838,1844],{},[42,1822,1823,1824],{},"Up: ",[23,1825,1826],{"href":30},"CLI project scaffolding with cookiecutter",[42,1828,1829],{},[23,1830,1831],{"href":25},"Building a cookiecutter template for Typer CLIs",[42,1833,1834],{},[23,1835,1837],{"href":1836},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fcopier-vs-cookiecutter-for-cli-templates\u002F","Copier vs cookiecutter for CLI templates",[42,1839,1840],{},[23,1841,1843],{"href":1842},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fcalling-external-commands-safely-with-subprocess\u002F","Calling external commands safely with subprocess",[42,1845,1846],{},[23,1847,1849],{"href":1848},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management\u002Fuv-init-vs-poetry-init-for-cli-tools\u002F","uv init vs Poetry init for CLI tools",[1851,1852,1853],"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 .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}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);}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}",{"title":103,"searchDepth":117,"depth":117,"links":1855},[1856,1857,1858,1859,1863,1864,1865,1866,1867,1873],{"id":36,"depth":117,"text":37},{"id":57,"depth":117,"text":58},{"id":92,"depth":117,"text":93},{"id":469,"depth":117,"text":470,"children":1860},[1861,1862],{"id":1123,"depth":128,"text":1124},{"id":1141,"depth":128,"text":1142},{"id":1178,"depth":117,"text":1179},{"id":1233,"depth":117,"text":1234},{"id":1267,"depth":117,"text":1268},{"id":1760,"depth":117,"text":1761},{"id":1767,"depth":117,"text":1768,"children":1868},[1869,1870,1871,1872],{"id":1771,"depth":128,"text":1772},{"id":1782,"depth":128,"text":1783},{"id":1791,"depth":128,"text":1792},{"id":1806,"depth":128,"text":1807},{"id":1817,"depth":117,"text":1818},"2026-09-18","Use cookiecutter pre- and post-generation hooks in CLI templates: validate answers, remove unused files, run git init and uv lock, print next steps, and test hooks.","intermediate",false,"md",{},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fpost-generation-hooks-in-cli-templates",{"title":5,"description":1875},"project-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fpost-generation-hooks-in-cli-templates\u002Findex",[1884,1885,1886,1887],"cookiecutter","templates","hooks","scaffolding","4ECNeDi95AmQl2T5OFUbaRTRoW6dlRNr6xYCjh_6nxI",[1890,1893,1896,1899,1902,1905,1908,1911,1914,1917,1920,1923,1926,1929,1932,1935,1938,1941,1944,1947,1950,1953,1956,1959,1962,1965,1968,1971,1974,1977,1980,1983,1986,1989,1992,1995,1998,2001,2004,2007,2010,2013,2016,2019,2022,2025,2028,2031,2034,2037,2040,2043,2046,2049,2052,2055,2058,2061,2064,2067,2070,2073,2076,2079,2082,2085,2088,2091,2094,2097,2100,2103,2106,2109,2112,2115,2118,2121,2124,2127,2130,2133,2136,2139,2142,2145,2148,2151,2154,2157,2160,2163,2165,2168,2171,2174,2177,2180,2183,2186,2189,2192,2195,2198,2201,2204,2207,2210,2213,2216,2219,2222,2225,2228,2231,2234,2237,2240,2243,2246,2249,2252,2255,2258,2261,2264,2267,2270,2273,2276,2279,2282,2285,2288,2291,2294,2297,2300,2303,2306,2309,2312,2315,2318,2319,2322,2325,2328,2331,2334,2337,2340,2343,2346,2349,2352,2355,2358,2361,2364,2367,2370,2373,2376,2379,2382,2385,2388,2391,2394,2397,2400,2403,2406,2409,2412,2415,2418,2421,2424,2427,2430,2433],{"path":1891,"title":1892},"\u002Fabout","About Python CLI Toolcraft",{"path":1894,"title":1895},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies","Advanced Argument Validation Strategies",{"path":1897,"title":1898},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fparsing-nested-json-arguments-in-python-clis","Parsing Nested JSON Args in Python CLIs",{"path":1900,"title":1901},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-dependent-and-conflicting-options","Validating Dependent and Conflicting CLI Options",{"path":1903,"title":1904},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-file-and-directory-paths-in-clis","Validating File and Directory Paths in CLIs",{"path":1906,"title":1907},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fwriting-custom-click-parameter-types","Writing Custom Click Parameter Types",{"path":1909,"title":1910},"\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":1912,"title":1913},"\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":1915,"title":1916},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual","Building Terminal UIs with Textual for Python CLIs",{"path":1918,"title":1919},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual\u002Ftesting-textual-apps-with-pilot","Testing Textual Apps with Pilot",{"path":1921,"title":1922},"\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":1924,"title":1925},"\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":1927,"title":1928},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation","CLI Help Output and Documentation",{"path":1930,"title":1931},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fversioning-and-deprecating-cli-flags","Versioning and Deprecating CLI Flags",{"path":1933,"title":1934},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fwriting-help-text-users-actually-read","Writing Help Text Users Actually Read",{"path":1936,"title":1937},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fadapting-output-to-terminal-width","Adapting Python CLI Output to Terminal Width",{"path":1939,"title":1940},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fdetecting-ci-environments-and-non-interactive-shells","Detecting CI Environments and Non-Interactive Shells",{"path":1942,"title":1943},"\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":1945,"title":1946},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility","Cross-Platform Terminal Compatibility for Python CLIs",{"path":1948,"title":1949},"\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":1951,"title":1952},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fchoosing-exit-codes-for-cli-tools","Choosing Exit Codes for CLI Tools",{"path":1954,"title":1955},"\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":1957,"title":1958},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Ffriendly-error-messages-and-tracebacks","Friendly Error Messages and Tracebacks",{"path":1960,"title":1961},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fhandling-keyboard-interrupt-cleanly","Handling Keyboard Interrupt Cleanly",{"path":1963,"title":1964},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes","Error Handling and Exit Codes for CLIs",{"path":1966,"title":1967},"\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":1969,"title":1970},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Fconfig-precedence-flags-env-files-defaults","Config Precedence: Flags, Env, Files, Defaults",{"path":1972,"title":1973},"\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":1975,"title":1976},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars","Handling Config Files and Env Vars in CLIs",{"path":1978,"title":1979},"\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":1981,"title":1982},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Freading-toml-config-with-tomllib","Reading TOML Config with tomllib in Python CLIs",{"path":1984,"title":1985},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Ftyped-settings-with-pydantic-settings","Typed Settings with pydantic-settings in Python CLIs",{"path":1987,"title":1988},"\u002Fadvanced-input-parsing-user-experience","Advanced Input Parsing for Python CLIs",{"path":1990,"title":1991},"\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":1993,"title":1994},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Fbuilding-interactive-prompts-and-menus","Building Interactive Prompts and Menus in Python CLIs",{"path":1996,"title":1997},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich","Interactive Terminal UI with Rich",{"path":1999,"title":2000},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Flive-dashboards-with-rich-live","Live Dashboards with Rich Live in Python CLIs",{"path":2002,"title":2003},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Frendering-tables-and-json-with-rich","Rendering Tables and JSON with Rich",{"path":2005,"title":2006},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Ftheming-rich-output-consistently","Theming Rich Output Consistently in Python CLIs",{"path":2008,"title":2009},"\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":2011,"title":2012},"\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":2014,"title":2015},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis","Shell Completion for Python CLIs",{"path":2017,"title":2018},"\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":2020,"title":2021},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis\u002Ftesting-shell-completion-in-python-clis","Testing Shell Completion in Python CLIs",{"path":2023,"title":2024},"\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":2026,"title":2027},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Fadding-verbose-and-quiet-logging-flags","Adding Verbose and Quiet Logging Flags",{"path":2029,"title":2030},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps","Structured Logging for CLI Apps",{"path":2032,"title":2033},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Fstructured-json-logging-in-python-clis","Structured JSON Logging in Python CLIs",{"path":2035,"title":2036},"\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":2038,"title":2039},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fdetecting-tty-and-adapting-output","Detecting a TTY and Adapting Output",{"path":2041,"title":2042},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Femitting-json-output-for-scripting","Emitting JSON Output for Scripting",{"path":2044,"title":2045},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fhandling-broken-pipe-and-sigpipe","Handling Broken Pipe and SIGPIPE",{"path":2047,"title":2048},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes","Working with stdin, stdout and Pipes",{"path":2050,"title":2051},"\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":2053,"title":2054},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Freading-piped-input-in-python-clis","Reading Piped Input in Python CLIs",{"path":2056,"title":2057},"\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":2059,"title":2060},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fdownloading-files-with-progress-in-python","Downloading Files with Progress in Python CLIs",{"path":2062,"title":2063},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis","Calling HTTP APIs from Python CLIs",{"path":2065,"title":2066},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Foauth-device-flow-login-for-clis","OAuth Device Flow Login for Python CLIs",{"path":2068,"title":2069},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fpaginating-api-results-in-a-cli","Paginating API Results in a Python CLI",{"path":2071,"title":2072},"\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":2074,"title":2075},"\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":2077,"title":2078},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis","Concurrency and Async in Python CLIs",{"path":2080,"title":2081},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Fmultiprocessing-for-cpu-bound-cli-tasks","Multiprocessing for CPU-Bound CLI Tasks",{"path":2083,"title":2084},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Fparallelising-cli-work-with-thread-pools","Parallelising CLI Work with Thread Pools",{"path":2086,"title":2087},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Frate-limiting-concurrent-requests-in-clis","Rate-Limiting Concurrent Requests in Python CLIs",{"path":2089,"title":2090},"\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":2092,"title":2093},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fcross-platform-paths-with-pathlib","Cross-Platform Paths with pathlib in CLIs",{"path":2095,"title":2096},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Ffile-locking-for-concurrent-cli-runs","File Locking for Concurrent CLI Runs in Python",{"path":2098,"title":2099},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes","Filesystem Paths and Atomic Writes for CLIs",{"path":2101,"title":2102},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fsafe-temporary-files-and-directories","Safe Temporary Files and Directories in CLIs",{"path":2104,"title":2105},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fstoring-app-data-with-platformdirs","Storing CLI App Data with platformdirs",{"path":2107,"title":2108},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fwriting-files-atomically-in-python-clis","Writing Files Atomically in Python CLIs",{"path":2110,"title":2111},"\u002Fcli-runtime-systems-integration","CLI Runtime & Systems Integration for Python",{"path":2113,"title":2114},"\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":2116,"title":2117},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Fhandling-sigterm-and-graceful-shutdown","Handling SIGTERM and Graceful Shutdown in CLIs",{"path":2119,"title":2120},"\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":2122,"title":2123},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis","Long-Running and Watch-Mode Python CLIs",{"path":2125,"title":2126},"\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":2128,"title":2129},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Favoiding-shell-injection-in-python-clis","Avoiding Shell Injection in Python CLIs",{"path":2131,"title":2132},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fcalling-external-commands-safely-with-subprocess","Calling External Commands Safely with subprocess",{"path":2134,"title":2135},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fhandling-subprocess-timeouts-and-exit-codes","Handling Subprocess Timeouts and Exit Codes",{"path":2137,"title":2138},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis","Running Subprocesses from Python CLIs",{"path":2140,"title":2141},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fstreaming-subprocess-output-in-real-time","Streaming Subprocess Output in Real Time",{"path":2143,"title":2144},"\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":2146,"title":2147},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis","Secrets and Credentials in Python CLIs",{"path":2149,"title":2150},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fprompting-for-passwords-securely","Prompting for Passwords Securely in Python CLIs",{"path":2152,"title":2153},"\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":2155,"title":2156},"\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":2158,"title":2159},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fstoring-tokens-with-keyring","Storing CLI Tokens Securely with keyring",{"path":2161,"title":2162},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fsupporting-multiple-profiles-and-accounts","Supporting Multiple Profiles and Accounts in CLIs",{"path":1490,"title":2164},"Python CLI Toolcraft",{"path":2166,"title":2167},"\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":2169,"title":2170},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading","CLI Startup Performance and Lazy Loading",{"path":2172,"title":2173},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Flazy-loading-subcommands-for-faster-startup","Lazy Loading Subcommands for Faster Startup",{"path":2175,"title":2176},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Fprofiling-python-cli-startup-time","Profiling Python CLI Startup Time",{"path":2178,"title":2179},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Freducing-cli-dependency-weight","Reducing CLI Dependency Weight",{"path":2181,"title":2182},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fargparse-subparsers-for-subcommands","argparse Subparsers for Subcommands",{"path":2184,"title":2185},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fargparse-vs-click-vs-typer-comparison","argparse vs Click vs Typer Compared",{"path":2187,"title":2188},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse","Command-Line Parsing with argparse",{"path":2190,"title":2191},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fmigrating-from-argparse-to-typer","Migrating from argparse to Typer",{"path":2193,"title":2194},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fmutually-exclusive-options-in-argparse","Mutually Exclusive Options in argparse",{"path":2196,"title":2197},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fwriting-custom-argparse-actions","Writing Custom argparse Actions in Python",{"path":2199,"title":2200},"\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":2202,"title":2203},"\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":2205,"title":2206},"\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":2208,"title":2209},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions","Designing CLI Interfaces and Conventions in Python",{"path":2211,"title":2212},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions\u002Fnaming-commands-and-flags-consistently","Naming Commands and Flags Consistently in Python CLIs",{"path":2214,"title":2215},"\u002Fmodern-python-cli-frameworks-architecture","Python CLI Frameworks and Architecture",{"path":2217,"title":2218},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fdiscovering-plugins-with-entry-points","Discovering Plugins with Entry Points in Python CLIs",{"path":2220,"title":2221},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fhook-based-plugins-with-pluggy","Hook-Based Plugins for Python CLIs with pluggy",{"path":2223,"title":2224},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis","Plugin Architectures for Extensible CLIs",{"path":2226,"title":2227},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fversioning-a-plugin-api","Versioning a Plugin API for a Python CLI",{"path":2229,"title":2230},"\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":2232,"title":2233},"\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":2235,"title":2236},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fdependency-injection-patterns-for-cli-commands","Dependency Injection Patterns for CLI Commands",{"path":2238,"title":2239},"\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":2241,"title":2242},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis","Structuring Multi-Command Python CLIs",{"path":2244,"title":2245},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fsharing-common-options-across-commands","Sharing Common Options Across Python CLI Commands",{"path":2247,"title":2248},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fsharing-state-with-click-context-objects","Sharing State with Click Context Objects",{"path":2250,"title":2251},"\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":2253,"title":2254},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications","Testing Python CLI Applications",{"path":2256,"title":2257},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fmeasuring-cli-test-coverage","Measuring CLI Test Coverage",{"path":2259,"title":2260},"\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":2262,"title":2263},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fproperty-based-testing-cli-arguments-with-hypothesis","Property-Based Testing CLI Arguments with Hypothesis",{"path":2265,"title":2266},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fsnapshot-testing-cli-output","Snapshot Testing CLI Output",{"path":2268,"title":2269},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Ftesting-click-commands-with-clirunner","Testing Click Commands with CliRunner",{"path":2271,"title":2272},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Ftesting-interactive-prompts-and-stdin","Testing Interactive Prompts and stdin",{"path":2274,"title":2275},"\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":2277,"title":2278},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fbuilding-dynamic-commands-in-click","Building Dynamic Commands in Click",{"path":2280,"title":2281},"\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":2283,"title":2284},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each","Typer vs Click: When to Use Each",{"path":2286,"title":2287},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Ftyper-callback-functions-explained","Typer callback functions explained",{"path":2289,"title":2290},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fusing-annotated-options-in-typer","Using Annotated Options in Typer",{"path":2292,"title":2293},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Fautomating-releases-from-git-tags","Automating Python CLI Releases from Git Tags",{"path":2295,"title":2296},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Fcaching-uv-dependencies-in-ci","Caching uv Dependencies in CI for Python CLIs",{"path":2298,"title":2299},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis","CI\u002FCD Pipelines for Python CLIs",{"path":2301,"title":2302},"\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":2304,"title":2305},"\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":2307,"title":2308},"\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":2310,"title":2311},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fbuilding-a-cookiecutter-template-for-typer-clis","Building a Cookiecutter Template for Typer CLIs",{"path":2313,"title":2314},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fcopier-vs-cookiecutter-for-cli-templates","Copier vs Cookiecutter for CLI Templates",{"path":2316,"title":2317},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter","CLI Project Scaffolding with Cookiecutter",{"path":1880,"title":5},{"path":2320,"title":2321},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fbuilding-cross-platform-release-binaries-in-ci","Building Cross-Platform Release Binaries in CI",{"path":2323,"title":2324},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fbundling-a-python-cli-with-pyinstaller","Bundling a Python CLI with PyInstaller",{"path":2326,"title":2327},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fhomebrew-and-scoop-packaging-for-python-clis","Homebrew and Scoop Packaging for Python CLIs",{"path":2329,"title":2330},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries","Distributing CLIs as Standalone Binaries",{"path":2332,"title":2333},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fnuitka-vs-pyinstaller-for-python-clis","Nuitka vs PyInstaller for Python CLI Binaries",{"path":2335,"title":2336},"\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":2338,"title":2339},"\u002Fproject-setup-dependency-management","Project Setup & Dependency Management",{"path":2341,"title":2342},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code\u002Fconfiguring-ruff-for-a-cli-project","Configuring Ruff for a Python CLI Project",{"path":2344,"title":2345},"\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":2347,"title":2348},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code","Linting and Type-Checking Python CLI Code",{"path":2350,"title":2351},"\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":2353,"title":2354},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fautomating-changelogs-with-conventional-commits","Automating Changelogs with Conventional Commits",{"path":2356,"title":2357},"\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":2359,"title":2360},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fexposing-version-info-and-build-metadata","Exposing Version Info and Build Metadata",{"path":2362,"title":2363},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs","Managing CLI Versioning & Changelogs",{"path":2365,"title":2366},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fsemantic-versioning-policy-for-cli-tools","A Semantic Versioning Policy for CLI Tools",{"path":2368,"title":2369},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fbuilding-wheels-and-sdists-for-python-clis","Building Wheels and sdists for Python CLIs",{"path":2371,"title":2372},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fbundling-data-files-with-importlib-resources","Bundling Data Files with importlib.resources in CLIs",{"path":2374,"title":2375},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution","Packaging Python CLIs for Distribution",{"path":2377,"title":2378},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Finstalling-and-distributing-clis-with-pipx","Installing and Distributing CLIs with pipx",{"path":2380,"title":2381},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fpublishing-a-python-cli-to-pypi","Publishing a Python CLI to PyPI",{"path":2383,"title":2384},"\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":2386,"title":2387},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development","Poetry Workflows for CLI Development",{"path":2389,"title":2390},"\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":2392,"title":2393},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fpoetry-dependency-groups-for-cli-tooling","Poetry Dependency Groups for CLI Tooling",{"path":2395,"title":2396},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fpoetry-entry-points-and-scripts-for-clis","Poetry Entry Points and Scripts for CLIs",{"path":2398,"title":2399},"\u002Fproject-setup-dependency-management\u002Fpre-commit-hooks-for-cli-projects","Pre-commit Hooks for CLI Projects",{"path":2401,"title":2402},"\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":2404,"title":2405},"\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":2407,"title":2408},"\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":2410,"title":2411},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management","uv for Python CLI Dependency Management",{"path":2413,"title":2414},"\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":2416,"title":2417},"\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":2419,"title":2420},"\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":2422,"title":2423},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management\u002Fuv-workspaces-for-multi-package-clis","uv Workspaces for Multi-Package Python CLIs",{"path":2425,"title":2426},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices","Python CLI Env Isolation Best Practices",{"path":2428,"title":2429},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fmanaging-virtual-environments-for-cross-platform-clis","Managing Python CLI Virtual Environments",{"path":2431,"title":2432},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fpinning-the-python-version-for-a-cli","Pinning the Python Version for a CLI",{"path":2434,"title":2435},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fsupporting-multiple-python-versions-with-nox","Supporting Multiple Python Versions with nox",1789736907478]