[{"data":1,"prerenderedAt":3388},["ShallowReactive",2],{"page-\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-dependent-and-conflicting-options\u002F":3,"content-directory":2840},{"id":4,"title":5,"body":6,"date":2826,"description":2827,"difficulty":2828,"draft":2829,"extension":2830,"meta":2831,"navigation":170,"path":2832,"seo":2833,"stem":2834,"tags":2835,"updated":2826,"__hash__":2839},"content\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-dependent-and-conflicting-options\u002Findex.md","Validating Dependent and Conflicting CLI Options",{"type":7,"value":8,"toc":2806},"minimark",[9,56,61,79,83,87,115,119,137,192,205,209,1217,1762,1765,1768,1857,1862,1873,2080,2111,2115,2122,2126,2129,2170,2174,2177,2668,2675,2679,2686,2690,2694,2701,2705,2726,2730,2752,2760,2767,2771,2802],[10,11,12,13,17,18,21,22,25,26,29,30,33,34,37,38,40,41,44,45,49,50,55],"p",{},"Real commands have options that interact. ",[14,15,16],"code",{},"--json"," and ",[14,19,20],{},"--csv"," cannot both be used. ",[14,23,24],{},"--cert"," is useless without ",[14,27,28],{},"--key",", and vice versa. ",[14,31,32],{},"--output-dir"," means nothing unless ",[14,35,36],{},"--save"," is also given. When these rules are not enforced, the tool silently picks one option or ignores another — the user asked for both JSON and CSV and gets JSON with no explanation, or passes ",[14,39,32],{}," and wonders why nothing was written. Click has no built-in syntax for such relationships, and scattering ",[14,42,43],{},"if"," checks through command bodies produces inconsistent messages and rules that are easy to forget. This guide declares relationships as small rule objects, checks them in one place after parsing, reports every violation as a standard usage error, and uses Click's ",[46,47,48],"strong",{},"parameter source"," to tell a value the user supplied from a default — the detail that makes these rules correct. It belongs to the ",[51,52,54],"a",{"href":53},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002F","advanced argument validation strategies topic",".",[57,58,60],"h2",{"id":59},"prerequisites","Prerequisites",[62,63,64,72],"ul",{},[65,66,67,68,71],"li",{},"Click 8.0+ (for ",[14,69,70],{},"Context.get_parameter_source",") or Typer; the rules module below works with both.",[65,73,74,75,55],{},"For argparse, the equivalent techniques are in ",[51,76,78],{"href":77},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fmutually-exclusive-options-in-argparse\u002F","mutually exclusive options in argparse",[57,80,82],{"id":81},"the-kinds-of-relationship","The kinds of relationship",[84,85],"inline-diagram",{"name":86},"dep-rules",[10,88,89,90,93,94,97,98,101,102,105,106,109,110,114],{},"Most relationships fall into a few shapes: ",[46,91,92],{},"exclusive"," (at most one of these), ",[46,95,96],{},"requires"," (if A then B), ",[46,99,100],{},"only with"," (A is meaningless without flag B), ",[46,103,104],{},"at least one of",", and relationships between ",[46,107,108],{},"values"," (the end date must follow the start date). The first three are about whether options were ",[111,112,113],"em",{},"given",", and are generic enough to express as reusable rules. Value relationships are specific to each command and belong in its body, right after the generic checks.",[57,116,118],{"id":117},"given-or-just-defaulted","Given, or just defaulted?",[10,120,121,122,124,125,128,129,132,133,136],{},"The subtle part of these rules is deciding whether an option was ",[46,123,113],{},". Checking ",[14,126,127],{},"if cert is not None"," works for options defaulting to ",[14,130,131],{},"None",", but fails for flags (which default to ",[14,134,135],{},"False","), for options with real defaults, and for options that can also come from an environment variable. Click records where each value came from:",[138,139,144],"pre",{"className":140,"code":141,"language":142,"meta":143,"style":143},"language-python shiki shiki-themes github-light github-dark","from click.core import ParameterSource\n\nctx.get_parameter_source(\"key\")\n# ParameterSource.COMMANDLINE, ENVIRONMENT, DEFAULT_MAP or DEFAULT\n","python","",[14,145,146,165,172,185],{"__ignoreMap":143},[147,148,151,155,159,162],"span",{"class":149,"line":150},"line",1,[147,152,154],{"class":153},"szBVR","from",[147,156,158],{"class":157},"sVt8B"," click.core ",[147,160,161],{"class":153},"import",[147,163,164],{"class":157}," ParameterSource\n",[147,166,168],{"class":149,"line":167},2,[147,169,171],{"emptyLinePlaceholder":170},true,"\n",[147,173,175,178,182],{"class":149,"line":174},3,[147,176,177],{"class":157},"ctx.get_parameter_source(",[147,179,181],{"class":180},"sZZnC","\"key\"",[147,183,184],{"class":157},")\n",[147,186,188],{"class":149,"line":187},4,[147,189,191],{"class":190},"sJ8bj","# ParameterSource.COMMANDLINE, ENVIRONMENT, DEFAULT_MAP or DEFAULT\n",[10,193,194,195,198,199,201,202,204],{},"Treating command-line and environment values as \"given\", and defaults as \"not given\", gives rules the meaning users expect: ",[14,196,197],{},"MYTOOL_KEY=k.pem mytool report --cert c.pem"," satisfies \"",[14,200,24],{}," requires ",[14,203,28],{},"\", while an option that merely has a default never triggers a conflict.",[57,206,208],{"id":207},"the-recipe","The recipe",[138,210,212],{"className":140,"code":211,"language":142,"meta":143,"style":143},"# src\u002Fmytool\u002Frules.py\nfrom __future__ import annotations\n\nimport functools\nfrom collections.abc import Callable\nfrom dataclasses import dataclass\nfrom typing import Any\n\nimport click\n\nGIVEN_SOURCES = {\"COMMANDLINE\", \"ENVIRONMENT\"}\n\n\ndef given(ctx: click.Context, name: str) -> bool:\n    \"\"\"True if the user supplied this parameter (flag or environment), not just the default.\n\n    Compares the source by name so it works with Click and with Typer's vendored copy of Click.\n    \"\"\"\n    source = ctx.get_parameter_source(name)\n    return source is not None and source.name in GIVEN_SOURCES\n\n\ndef flag(ctx: click.Context, name: str) -> str:\n    param = next(p for p in ctx.command.params if p.name == name)\n    return param.opts[0] if getattr(param, \"opts\", None) else name.upper()\n\n\n@dataclass(frozen=True)\nclass Exclusive:\n    names: tuple[str, ...]\n\n    def check(self, ctx: click.Context) -> str | None:\n        used = [n for n in self.names if given(ctx, n)]\n        if len(used) > 1:\n            return f\"{flag(ctx, used[0])} cannot be used together with {flag(ctx, used[1])}.\"\n        return None\n\n\n@dataclass(frozen=True)\nclass Requires:\n    name: str\n    needs: str\n\n    def check(self, ctx: click.Context) -> str | None:\n        if given(ctx, self.name) and not given(ctx, self.needs):\n            return f\"{flag(ctx, self.name)} requires {flag(ctx, self.needs)}.\"\n        return None\n\n\n@dataclass(frozen=True)\nclass OnlyWith:\n    name: str\n    flag_name: str\n\n    def check(self, ctx: click.Context) -> str | None:\n        if given(ctx, self.name) and not ctx.params.get(self.flag_name):\n            return f\"{flag(ctx, self.name)} is only allowed with {flag(ctx, self.flag_name)}.\"\n        return None\n\n\ndef check_rules(ctx: click.Context, *rules: Any) -> None:\n    \"\"\"Raise one UsageError listing every violated rule.\"\"\"\n    problems = [msg for rule in rules if (msg := rule.check(ctx))]\n    if problems:\n        ctx.fail(\" \".join(problems))          # the context's own UsageError: exit status 2\n\n\ndef enforce(*rules: Any) -> Callable:\n    \"\"\"Click decorator: check option relationships after parsing, before the body runs.\"\"\"\n\n    def decorator(f: Callable) -> Callable:\n        @functools.wraps(f)\n        def wrapper(*args: Any, **kwargs: Any) -> Any:\n            check_rules(click.get_current_context(), *rules)\n            return f(*args, **kwargs)\n\n        return wrapper\n\n    return decorator\n",[14,213,214,219,233,237,244,257,270,283,288,296,301,325,330,335,360,366,371,377,383,395,425,430,435,453,489,527,532,537,557,568,584,589,610,639,659,702,711,716,721,736,746,755,763,768,785,811,847,854,859,864,879,889,896,904,909,926,949,984,991,996,1001,1022,1028,1060,1069,1084,1089,1094,1109,1115,1120,1131,1140,1162,1173,1191,1196,1204,1209],{"__ignoreMap":143},[147,215,216],{"class":149,"line":150},[147,217,218],{"class":190},"# src\u002Fmytool\u002Frules.py\n",[147,220,221,223,227,230],{"class":149,"line":167},[147,222,154],{"class":153},[147,224,226],{"class":225},"sj4cs"," __future__",[147,228,229],{"class":153}," import",[147,231,232],{"class":157}," annotations\n",[147,234,235],{"class":149,"line":174},[147,236,171],{"emptyLinePlaceholder":170},[147,238,239,241],{"class":149,"line":187},[147,240,161],{"class":153},[147,242,243],{"class":157}," functools\n",[147,245,247,249,252,254],{"class":149,"line":246},5,[147,248,154],{"class":153},[147,250,251],{"class":157}," collections.abc ",[147,253,161],{"class":153},[147,255,256],{"class":157}," Callable\n",[147,258,260,262,265,267],{"class":149,"line":259},6,[147,261,154],{"class":153},[147,263,264],{"class":157}," dataclasses ",[147,266,161],{"class":153},[147,268,269],{"class":157}," dataclass\n",[147,271,273,275,278,280],{"class":149,"line":272},7,[147,274,154],{"class":153},[147,276,277],{"class":157}," typing ",[147,279,161],{"class":153},[147,281,282],{"class":157}," Any\n",[147,284,286],{"class":149,"line":285},8,[147,287,171],{"emptyLinePlaceholder":170},[147,289,291,293],{"class":149,"line":290},9,[147,292,161],{"class":153},[147,294,295],{"class":157}," click\n",[147,297,299],{"class":149,"line":298},10,[147,300,171],{"emptyLinePlaceholder":170},[147,302,304,307,310,313,316,319,322],{"class":149,"line":303},11,[147,305,306],{"class":225},"GIVEN_SOURCES",[147,308,309],{"class":153}," =",[147,311,312],{"class":157}," {",[147,314,315],{"class":180},"\"COMMANDLINE\"",[147,317,318],{"class":157},", ",[147,320,321],{"class":180},"\"ENVIRONMENT\"",[147,323,324],{"class":157},"}\n",[147,326,328],{"class":149,"line":327},12,[147,329,171],{"emptyLinePlaceholder":170},[147,331,333],{"class":149,"line":332},13,[147,334,171],{"emptyLinePlaceholder":170},[147,336,338,341,345,348,351,354,357],{"class":149,"line":337},14,[147,339,340],{"class":153},"def",[147,342,344],{"class":343},"sScJk"," given",[147,346,347],{"class":157},"(ctx: click.Context, name: ",[147,349,350],{"class":225},"str",[147,352,353],{"class":157},") -> ",[147,355,356],{"class":225},"bool",[147,358,359],{"class":157},":\n",[147,361,363],{"class":149,"line":362},15,[147,364,365],{"class":180},"    \"\"\"True if the user supplied this parameter (flag or environment), not just the default.\n",[147,367,369],{"class":149,"line":368},16,[147,370,171],{"emptyLinePlaceholder":170},[147,372,374],{"class":149,"line":373},17,[147,375,376],{"class":180},"    Compares the source by name so it works with Click and with Typer's vendored copy of Click.\n",[147,378,380],{"class":149,"line":379},18,[147,381,382],{"class":180},"    \"\"\"\n",[147,384,386,389,392],{"class":149,"line":385},19,[147,387,388],{"class":157},"    source ",[147,390,391],{"class":153},"=",[147,393,394],{"class":157}," ctx.get_parameter_source(name)\n",[147,396,398,401,404,407,410,413,416,419,422],{"class":149,"line":397},20,[147,399,400],{"class":153},"    return",[147,402,403],{"class":157}," source ",[147,405,406],{"class":153},"is",[147,408,409],{"class":153}," not",[147,411,412],{"class":225}," None",[147,414,415],{"class":153}," and",[147,417,418],{"class":157}," source.name ",[147,420,421],{"class":153},"in",[147,423,424],{"class":225}," GIVEN_SOURCES\n",[147,426,428],{"class":149,"line":427},21,[147,429,171],{"emptyLinePlaceholder":170},[147,431,433],{"class":149,"line":432},22,[147,434,171],{"emptyLinePlaceholder":170},[147,436,438,440,443,445,447,449,451],{"class":149,"line":437},23,[147,439,340],{"class":153},[147,441,442],{"class":343}," flag",[147,444,347],{"class":157},[147,446,350],{"class":225},[147,448,353],{"class":157},[147,450,350],{"class":225},[147,452,359],{"class":157},[147,454,456,459,461,464,467,470,473,475,478,480,483,486],{"class":149,"line":455},24,[147,457,458],{"class":157},"    param ",[147,460,391],{"class":153},[147,462,463],{"class":225}," next",[147,465,466],{"class":157},"(p ",[147,468,469],{"class":153},"for",[147,471,472],{"class":157}," p ",[147,474,421],{"class":153},[147,476,477],{"class":157}," ctx.command.params ",[147,479,43],{"class":153},[147,481,482],{"class":157}," p.name ",[147,484,485],{"class":153},"==",[147,487,488],{"class":157}," name)\n",[147,490,492,494,497,500,503,505,508,511,514,516,518,521,524],{"class":149,"line":491},25,[147,493,400],{"class":153},[147,495,496],{"class":157}," param.opts[",[147,498,499],{"class":225},"0",[147,501,502],{"class":157},"] ",[147,504,43],{"class":153},[147,506,507],{"class":225}," getattr",[147,509,510],{"class":157},"(param, ",[147,512,513],{"class":180},"\"opts\"",[147,515,318],{"class":157},[147,517,131],{"class":225},[147,519,520],{"class":157},") ",[147,522,523],{"class":153},"else",[147,525,526],{"class":157}," name.upper()\n",[147,528,530],{"class":149,"line":529},26,[147,531,171],{"emptyLinePlaceholder":170},[147,533,535],{"class":149,"line":534},27,[147,536,171],{"emptyLinePlaceholder":170},[147,538,540,543,546,550,552,555],{"class":149,"line":539},28,[147,541,542],{"class":343},"@dataclass",[147,544,545],{"class":157},"(",[147,547,549],{"class":548},"s4XuR","frozen",[147,551,391],{"class":153},[147,553,554],{"class":225},"True",[147,556,184],{"class":157},[147,558,560,563,566],{"class":149,"line":559},29,[147,561,562],{"class":153},"class",[147,564,565],{"class":343}," Exclusive",[147,567,359],{"class":157},[147,569,571,574,576,578,581],{"class":149,"line":570},30,[147,572,573],{"class":157},"    names: tuple[",[147,575,350],{"class":225},[147,577,318],{"class":157},[147,579,580],{"class":225},"...",[147,582,583],{"class":157},"]\n",[147,585,587],{"class":149,"line":586},31,[147,588,171],{"emptyLinePlaceholder":170},[147,590,592,595,598,601,603,606,608],{"class":149,"line":591},32,[147,593,594],{"class":153},"    def",[147,596,597],{"class":343}," check",[147,599,600],{"class":157},"(self, ctx: click.Context) -> ",[147,602,350],{"class":225},[147,604,605],{"class":153}," |",[147,607,412],{"class":225},[147,609,359],{"class":157},[147,611,613,616,618,621,623,626,628,631,634,636],{"class":149,"line":612},33,[147,614,615],{"class":157},"        used ",[147,617,391],{"class":153},[147,619,620],{"class":157}," [n ",[147,622,469],{"class":153},[147,624,625],{"class":157}," n ",[147,627,421],{"class":153},[147,629,630],{"class":225}," self",[147,632,633],{"class":157},".names ",[147,635,43],{"class":153},[147,637,638],{"class":157}," given(ctx, n)]\n",[147,640,642,645,648,651,654,657],{"class":149,"line":641},34,[147,643,644],{"class":153},"        if",[147,646,647],{"class":225}," len",[147,649,650],{"class":157},"(used) ",[147,652,653],{"class":153},">",[147,655,656],{"class":225}," 1",[147,658,359],{"class":157},[147,660,662,665,668,671,674,677,679,682,685,688,690,692,695,697,699],{"class":149,"line":661},35,[147,663,664],{"class":153},"            return",[147,666,667],{"class":153}," f",[147,669,670],{"class":180},"\"",[147,672,673],{"class":225},"{",[147,675,676],{"class":157},"flag(ctx, used[",[147,678,499],{"class":225},[147,680,681],{"class":157},"])",[147,683,684],{"class":225},"}",[147,686,687],{"class":180}," cannot be used together with ",[147,689,673],{"class":225},[147,691,676],{"class":157},[147,693,694],{"class":225},"1",[147,696,681],{"class":157},[147,698,684],{"class":225},[147,700,701],{"class":180},".\"\n",[147,703,705,708],{"class":149,"line":704},36,[147,706,707],{"class":153},"        return",[147,709,710],{"class":225}," None\n",[147,712,714],{"class":149,"line":713},37,[147,715,171],{"emptyLinePlaceholder":170},[147,717,719],{"class":149,"line":718},38,[147,720,171],{"emptyLinePlaceholder":170},[147,722,724,726,728,730,732,734],{"class":149,"line":723},39,[147,725,542],{"class":343},[147,727,545],{"class":157},[147,729,549],{"class":548},[147,731,391],{"class":153},[147,733,554],{"class":225},[147,735,184],{"class":157},[147,737,739,741,744],{"class":149,"line":738},40,[147,740,562],{"class":153},[147,742,743],{"class":343}," Requires",[147,745,359],{"class":157},[147,747,749,752],{"class":149,"line":748},41,[147,750,751],{"class":157},"    name: ",[147,753,754],{"class":225},"str\n",[147,756,758,761],{"class":149,"line":757},42,[147,759,760],{"class":157},"    needs: ",[147,762,754],{"class":225},[147,764,766],{"class":149,"line":765},43,[147,767,171],{"emptyLinePlaceholder":170},[147,769,771,773,775,777,779,781,783],{"class":149,"line":770},44,[147,772,594],{"class":153},[147,774,597],{"class":343},[147,776,600],{"class":157},[147,778,350],{"class":225},[147,780,605],{"class":153},[147,782,412],{"class":225},[147,784,359],{"class":157},[147,786,788,790,793,796,799,802,804,806,808],{"class":149,"line":787},45,[147,789,644],{"class":153},[147,791,792],{"class":157}," given(ctx, ",[147,794,795],{"class":225},"self",[147,797,798],{"class":157},".name) ",[147,800,801],{"class":153},"and",[147,803,409],{"class":153},[147,805,792],{"class":157},[147,807,795],{"class":225},[147,809,810],{"class":157},".needs):\n",[147,812,814,816,818,820,822,825,827,830,832,834,836,838,840,843,845],{"class":149,"line":813},46,[147,815,664],{"class":153},[147,817,667],{"class":153},[147,819,670],{"class":180},[147,821,673],{"class":225},[147,823,824],{"class":157},"flag(ctx, ",[147,826,795],{"class":225},[147,828,829],{"class":157},".name)",[147,831,684],{"class":225},[147,833,201],{"class":180},[147,835,673],{"class":225},[147,837,824],{"class":157},[147,839,795],{"class":225},[147,841,842],{"class":157},".needs)",[147,844,684],{"class":225},[147,846,701],{"class":180},[147,848,850,852],{"class":149,"line":849},47,[147,851,707],{"class":153},[147,853,710],{"class":225},[147,855,857],{"class":149,"line":856},48,[147,858,171],{"emptyLinePlaceholder":170},[147,860,862],{"class":149,"line":861},49,[147,863,171],{"emptyLinePlaceholder":170},[147,865,867,869,871,873,875,877],{"class":149,"line":866},50,[147,868,542],{"class":343},[147,870,545],{"class":157},[147,872,549],{"class":548},[147,874,391],{"class":153},[147,876,554],{"class":225},[147,878,184],{"class":157},[147,880,882,884,887],{"class":149,"line":881},51,[147,883,562],{"class":153},[147,885,886],{"class":343}," OnlyWith",[147,888,359],{"class":157},[147,890,892,894],{"class":149,"line":891},52,[147,893,751],{"class":157},[147,895,754],{"class":225},[147,897,899,902],{"class":149,"line":898},53,[147,900,901],{"class":157},"    flag_name: ",[147,903,754],{"class":225},[147,905,907],{"class":149,"line":906},54,[147,908,171],{"emptyLinePlaceholder":170},[147,910,912,914,916,918,920,922,924],{"class":149,"line":911},55,[147,913,594],{"class":153},[147,915,597],{"class":343},[147,917,600],{"class":157},[147,919,350],{"class":225},[147,921,605],{"class":153},[147,923,412],{"class":225},[147,925,359],{"class":157},[147,927,929,931,933,935,937,939,941,944,946],{"class":149,"line":928},56,[147,930,644],{"class":153},[147,932,792],{"class":157},[147,934,795],{"class":225},[147,936,798],{"class":157},[147,938,801],{"class":153},[147,940,409],{"class":153},[147,942,943],{"class":157}," ctx.params.get(",[147,945,795],{"class":225},[147,947,948],{"class":157},".flag_name):\n",[147,950,952,954,956,958,960,962,964,966,968,971,973,975,977,980,982],{"class":149,"line":951},57,[147,953,664],{"class":153},[147,955,667],{"class":153},[147,957,670],{"class":180},[147,959,673],{"class":225},[147,961,824],{"class":157},[147,963,795],{"class":225},[147,965,829],{"class":157},[147,967,684],{"class":225},[147,969,970],{"class":180}," is only allowed with ",[147,972,673],{"class":225},[147,974,824],{"class":157},[147,976,795],{"class":225},[147,978,979],{"class":157},".flag_name)",[147,981,684],{"class":225},[147,983,701],{"class":180},[147,985,987,989],{"class":149,"line":986},58,[147,988,707],{"class":153},[147,990,710],{"class":225},[147,992,994],{"class":149,"line":993},59,[147,995,171],{"emptyLinePlaceholder":170},[147,997,999],{"class":149,"line":998},60,[147,1000,171],{"emptyLinePlaceholder":170},[147,1002,1004,1006,1009,1012,1015,1018,1020],{"class":149,"line":1003},61,[147,1005,340],{"class":153},[147,1007,1008],{"class":343}," check_rules",[147,1010,1011],{"class":157},"(ctx: click.Context, ",[147,1013,1014],{"class":153},"*",[147,1016,1017],{"class":157},"rules: Any) -> ",[147,1019,131],{"class":225},[147,1021,359],{"class":157},[147,1023,1025],{"class":149,"line":1024},62,[147,1026,1027],{"class":180},"    \"\"\"Raise one UsageError listing every violated rule.\"\"\"\n",[147,1029,1031,1034,1036,1039,1041,1044,1046,1049,1051,1054,1057],{"class":149,"line":1030},63,[147,1032,1033],{"class":157},"    problems ",[147,1035,391],{"class":153},[147,1037,1038],{"class":157}," [msg ",[147,1040,469],{"class":153},[147,1042,1043],{"class":157}," rule ",[147,1045,421],{"class":153},[147,1047,1048],{"class":157}," rules ",[147,1050,43],{"class":153},[147,1052,1053],{"class":157}," (msg ",[147,1055,1056],{"class":153},":=",[147,1058,1059],{"class":157}," rule.check(ctx))]\n",[147,1061,1063,1066],{"class":149,"line":1062},64,[147,1064,1065],{"class":153},"    if",[147,1067,1068],{"class":157}," problems:\n",[147,1070,1072,1075,1078,1081],{"class":149,"line":1071},65,[147,1073,1074],{"class":157},"        ctx.fail(",[147,1076,1077],{"class":180},"\" \"",[147,1079,1080],{"class":157},".join(problems))          ",[147,1082,1083],{"class":190},"# the context's own UsageError: exit status 2\n",[147,1085,1087],{"class":149,"line":1086},66,[147,1088,171],{"emptyLinePlaceholder":170},[147,1090,1092],{"class":149,"line":1091},67,[147,1093,171],{"emptyLinePlaceholder":170},[147,1095,1097,1099,1102,1104,1106],{"class":149,"line":1096},68,[147,1098,340],{"class":153},[147,1100,1101],{"class":343}," enforce",[147,1103,545],{"class":157},[147,1105,1014],{"class":153},[147,1107,1108],{"class":157},"rules: Any) -> Callable:\n",[147,1110,1112],{"class":149,"line":1111},69,[147,1113,1114],{"class":180},"    \"\"\"Click decorator: check option relationships after parsing, before the body runs.\"\"\"\n",[147,1116,1118],{"class":149,"line":1117},70,[147,1119,171],{"emptyLinePlaceholder":170},[147,1121,1123,1125,1128],{"class":149,"line":1122},71,[147,1124,594],{"class":153},[147,1126,1127],{"class":343}," decorator",[147,1129,1130],{"class":157},"(f: Callable) -> Callable:\n",[147,1132,1134,1137],{"class":149,"line":1133},72,[147,1135,1136],{"class":343},"        @functools.wraps",[147,1138,1139],{"class":157},"(f)\n",[147,1141,1143,1146,1149,1151,1153,1156,1159],{"class":149,"line":1142},73,[147,1144,1145],{"class":153},"        def",[147,1147,1148],{"class":343}," wrapper",[147,1150,545],{"class":157},[147,1152,1014],{"class":153},[147,1154,1155],{"class":157},"args: Any, ",[147,1157,1158],{"class":153},"**",[147,1160,1161],{"class":157},"kwargs: Any) -> Any:\n",[147,1163,1165,1168,1170],{"class":149,"line":1164},74,[147,1166,1167],{"class":157},"            check_rules(click.get_current_context(), ",[147,1169,1014],{"class":153},[147,1171,1172],{"class":157},"rules)\n",[147,1174,1176,1178,1181,1183,1186,1188],{"class":149,"line":1175},75,[147,1177,664],{"class":153},[147,1179,1180],{"class":157}," f(",[147,1182,1014],{"class":153},[147,1184,1185],{"class":157},"args, ",[147,1187,1158],{"class":153},[147,1189,1190],{"class":157},"kwargs)\n",[147,1192,1194],{"class":149,"line":1193},76,[147,1195,171],{"emptyLinePlaceholder":170},[147,1197,1199,1201],{"class":149,"line":1198},77,[147,1200,707],{"class":153},[147,1202,1203],{"class":157}," wrapper\n",[147,1205,1207],{"class":149,"line":1206},78,[147,1208,171],{"emptyLinePlaceholder":170},[147,1210,1212,1214],{"class":149,"line":1211},79,[147,1213,400],{"class":153},[147,1215,1216],{"class":157}," decorator\n",[138,1218,1220],{"className":140,"code":1219,"language":142,"meta":143,"style":143},"# src\u002Fmytool\u002Fcli.py\nfrom pathlib import Path\n\nimport click\n\nfrom mytool.rules import Exclusive, OnlyWith, Requires, enforce\n\n\n@click.group()\ndef cli() -> None:\n    \"\"\"Reporting tool.\"\"\"\n\n\n@cli.command()\n@click.option(\"--json\", \"as_json\", is_flag=True, help=\"JSON output.\")\n@click.option(\"--csv\", \"as_csv\", is_flag=True, help=\"CSV output.\")\n@click.option(\"--save\", is_flag=True, help=\"Save the report instead of printing it.\")\n@click.option(\"--output-dir\", type=click.Path(path_type=Path), help=\"Where to save (requires --save).\")\n@click.option(\"--cert\", type=click.Path(path_type=Path), help=\"Client certificate.\")\n@click.option(\"--key\", type=click.Path(path_type=Path), envvar=\"MYTOOL_KEY\", help=\"Client key.\")\n@enforce(\n    Exclusive((\"as_json\", \"as_csv\")),\n    OnlyWith(\"output_dir\", \"save\"),\n    Requires(\"cert\", \"key\"),\n    Requires(\"key\", \"cert\"),\n)\ndef report(as_json: bool, as_csv: bool, save: bool, output_dir: Path | None,\n           cert: Path | None, key: Path | None) -> None:\n    \"\"\"Build a report.\"\"\"\n    fmt = \"json\" if as_json else \"csv\" if as_csv else \"table\"\n    click.echo(f\"format={fmt} save={save} dir={output_dir} tls={bool(cert)}\")\n\n\nif __name__ == \"__main__\":\n    cli()\n",[14,1221,1222,1227,1239,1243,1249,1253,1265,1269,1273,1281,1295,1300,1304,1308,1315,1351,1384,1412,1448,1480,1522,1530,1544,1560,1574,1586,1590,1623,1645,1650,1681,1734,1738,1742,1757],{"__ignoreMap":143},[147,1223,1224],{"class":149,"line":150},[147,1225,1226],{"class":190},"# src\u002Fmytool\u002Fcli.py\n",[147,1228,1229,1231,1234,1236],{"class":149,"line":167},[147,1230,154],{"class":153},[147,1232,1233],{"class":157}," pathlib ",[147,1235,161],{"class":153},[147,1237,1238],{"class":157}," Path\n",[147,1240,1241],{"class":149,"line":174},[147,1242,171],{"emptyLinePlaceholder":170},[147,1244,1245,1247],{"class":149,"line":187},[147,1246,161],{"class":153},[147,1248,295],{"class":157},[147,1250,1251],{"class":149,"line":246},[147,1252,171],{"emptyLinePlaceholder":170},[147,1254,1255,1257,1260,1262],{"class":149,"line":259},[147,1256,154],{"class":153},[147,1258,1259],{"class":157}," mytool.rules ",[147,1261,161],{"class":153},[147,1263,1264],{"class":157}," Exclusive, OnlyWith, Requires, enforce\n",[147,1266,1267],{"class":149,"line":272},[147,1268,171],{"emptyLinePlaceholder":170},[147,1270,1271],{"class":149,"line":285},[147,1272,171],{"emptyLinePlaceholder":170},[147,1274,1275,1278],{"class":149,"line":290},[147,1276,1277],{"class":343},"@click.group",[147,1279,1280],{"class":157},"()\n",[147,1282,1283,1285,1288,1291,1293],{"class":149,"line":298},[147,1284,340],{"class":153},[147,1286,1287],{"class":343}," cli",[147,1289,1290],{"class":157},"() -> ",[147,1292,131],{"class":225},[147,1294,359],{"class":157},[147,1296,1297],{"class":149,"line":303},[147,1298,1299],{"class":180},"    \"\"\"Reporting tool.\"\"\"\n",[147,1301,1302],{"class":149,"line":327},[147,1303,171],{"emptyLinePlaceholder":170},[147,1305,1306],{"class":149,"line":332},[147,1307,171],{"emptyLinePlaceholder":170},[147,1309,1310,1313],{"class":149,"line":337},[147,1311,1312],{"class":343},"@cli.command",[147,1314,1280],{"class":157},[147,1316,1317,1320,1322,1325,1327,1330,1332,1335,1337,1339,1341,1344,1346,1349],{"class":149,"line":362},[147,1318,1319],{"class":343},"@click.option",[147,1321,545],{"class":157},[147,1323,1324],{"class":180},"\"--json\"",[147,1326,318],{"class":157},[147,1328,1329],{"class":180},"\"as_json\"",[147,1331,318],{"class":157},[147,1333,1334],{"class":548},"is_flag",[147,1336,391],{"class":153},[147,1338,554],{"class":225},[147,1340,318],{"class":157},[147,1342,1343],{"class":548},"help",[147,1345,391],{"class":153},[147,1347,1348],{"class":180},"\"JSON output.\"",[147,1350,184],{"class":157},[147,1352,1353,1355,1357,1360,1362,1365,1367,1369,1371,1373,1375,1377,1379,1382],{"class":149,"line":368},[147,1354,1319],{"class":343},[147,1356,545],{"class":157},[147,1358,1359],{"class":180},"\"--csv\"",[147,1361,318],{"class":157},[147,1363,1364],{"class":180},"\"as_csv\"",[147,1366,318],{"class":157},[147,1368,1334],{"class":548},[147,1370,391],{"class":153},[147,1372,554],{"class":225},[147,1374,318],{"class":157},[147,1376,1343],{"class":548},[147,1378,391],{"class":153},[147,1380,1381],{"class":180},"\"CSV output.\"",[147,1383,184],{"class":157},[147,1385,1386,1388,1390,1393,1395,1397,1399,1401,1403,1405,1407,1410],{"class":149,"line":373},[147,1387,1319],{"class":343},[147,1389,545],{"class":157},[147,1391,1392],{"class":180},"\"--save\"",[147,1394,318],{"class":157},[147,1396,1334],{"class":548},[147,1398,391],{"class":153},[147,1400,554],{"class":225},[147,1402,318],{"class":157},[147,1404,1343],{"class":548},[147,1406,391],{"class":153},[147,1408,1409],{"class":180},"\"Save the report instead of printing it.\"",[147,1411,184],{"class":157},[147,1413,1414,1416,1418,1421,1423,1426,1428,1431,1434,1436,1439,1441,1443,1446],{"class":149,"line":379},[147,1415,1319],{"class":343},[147,1417,545],{"class":157},[147,1419,1420],{"class":180},"\"--output-dir\"",[147,1422,318],{"class":157},[147,1424,1425],{"class":548},"type",[147,1427,391],{"class":153},[147,1429,1430],{"class":157},"click.Path(",[147,1432,1433],{"class":548},"path_type",[147,1435,391],{"class":153},[147,1437,1438],{"class":157},"Path), ",[147,1440,1343],{"class":548},[147,1442,391],{"class":153},[147,1444,1445],{"class":180},"\"Where to save (requires --save).\"",[147,1447,184],{"class":157},[147,1449,1450,1452,1454,1457,1459,1461,1463,1465,1467,1469,1471,1473,1475,1478],{"class":149,"line":385},[147,1451,1319],{"class":343},[147,1453,545],{"class":157},[147,1455,1456],{"class":180},"\"--cert\"",[147,1458,318],{"class":157},[147,1460,1425],{"class":548},[147,1462,391],{"class":153},[147,1464,1430],{"class":157},[147,1466,1433],{"class":548},[147,1468,391],{"class":153},[147,1470,1438],{"class":157},[147,1472,1343],{"class":548},[147,1474,391],{"class":153},[147,1476,1477],{"class":180},"\"Client certificate.\"",[147,1479,184],{"class":157},[147,1481,1482,1484,1486,1489,1491,1493,1495,1497,1499,1501,1503,1506,1508,1511,1513,1515,1517,1520],{"class":149,"line":397},[147,1483,1319],{"class":343},[147,1485,545],{"class":157},[147,1487,1488],{"class":180},"\"--key\"",[147,1490,318],{"class":157},[147,1492,1425],{"class":548},[147,1494,391],{"class":153},[147,1496,1430],{"class":157},[147,1498,1433],{"class":548},[147,1500,391],{"class":153},[147,1502,1438],{"class":157},[147,1504,1505],{"class":548},"envvar",[147,1507,391],{"class":153},[147,1509,1510],{"class":180},"\"MYTOOL_KEY\"",[147,1512,318],{"class":157},[147,1514,1343],{"class":548},[147,1516,391],{"class":153},[147,1518,1519],{"class":180},"\"Client key.\"",[147,1521,184],{"class":157},[147,1523,1524,1527],{"class":149,"line":427},[147,1525,1526],{"class":343},"@enforce",[147,1528,1529],{"class":157},"(\n",[147,1531,1532,1535,1537,1539,1541],{"class":149,"line":432},[147,1533,1534],{"class":157},"    Exclusive((",[147,1536,1329],{"class":180},[147,1538,318],{"class":157},[147,1540,1364],{"class":180},[147,1542,1543],{"class":157},")),\n",[147,1545,1546,1549,1552,1554,1557],{"class":149,"line":437},[147,1547,1548],{"class":157},"    OnlyWith(",[147,1550,1551],{"class":180},"\"output_dir\"",[147,1553,318],{"class":157},[147,1555,1556],{"class":180},"\"save\"",[147,1558,1559],{"class":157},"),\n",[147,1561,1562,1565,1568,1570,1572],{"class":149,"line":455},[147,1563,1564],{"class":157},"    Requires(",[147,1566,1567],{"class":180},"\"cert\"",[147,1569,318],{"class":157},[147,1571,181],{"class":180},[147,1573,1559],{"class":157},[147,1575,1576,1578,1580,1582,1584],{"class":149,"line":491},[147,1577,1564],{"class":157},[147,1579,181],{"class":180},[147,1581,318],{"class":157},[147,1583,1567],{"class":180},[147,1585,1559],{"class":157},[147,1587,1588],{"class":149,"line":529},[147,1589,184],{"class":157},[147,1591,1592,1594,1597,1600,1602,1605,1607,1610,1612,1615,1618,1620],{"class":149,"line":534},[147,1593,340],{"class":153},[147,1595,1596],{"class":343}," report",[147,1598,1599],{"class":157},"(as_json: ",[147,1601,356],{"class":225},[147,1603,1604],{"class":157},", as_csv: ",[147,1606,356],{"class":225},[147,1608,1609],{"class":157},", save: ",[147,1611,356],{"class":225},[147,1613,1614],{"class":157},", output_dir: Path ",[147,1616,1617],{"class":153},"|",[147,1619,412],{"class":225},[147,1621,1622],{"class":157},",\n",[147,1624,1625,1628,1630,1632,1635,1637,1639,1641,1643],{"class":149,"line":539},[147,1626,1627],{"class":157},"           cert: Path ",[147,1629,1617],{"class":153},[147,1631,412],{"class":225},[147,1633,1634],{"class":157},", key: Path ",[147,1636,1617],{"class":153},[147,1638,412],{"class":225},[147,1640,353],{"class":157},[147,1642,131],{"class":225},[147,1644,359],{"class":157},[147,1646,1647],{"class":149,"line":559},[147,1648,1649],{"class":180},"    \"\"\"Build a report.\"\"\"\n",[147,1651,1652,1655,1657,1660,1663,1666,1668,1671,1673,1676,1678],{"class":149,"line":570},[147,1653,1654],{"class":157},"    fmt ",[147,1656,391],{"class":153},[147,1658,1659],{"class":180}," \"json\"",[147,1661,1662],{"class":153}," if",[147,1664,1665],{"class":157}," as_json ",[147,1667,523],{"class":153},[147,1669,1670],{"class":180}," \"csv\"",[147,1672,1662],{"class":153},[147,1674,1675],{"class":157}," as_csv ",[147,1677,523],{"class":153},[147,1679,1680],{"class":180}," \"table\"\n",[147,1682,1683,1686,1689,1692,1694,1697,1699,1702,1704,1707,1709,1712,1714,1717,1719,1722,1725,1728,1730,1732],{"class":149,"line":586},[147,1684,1685],{"class":157},"    click.echo(",[147,1687,1688],{"class":153},"f",[147,1690,1691],{"class":180},"\"format=",[147,1693,673],{"class":225},[147,1695,1696],{"class":157},"fmt",[147,1698,684],{"class":225},[147,1700,1701],{"class":180}," save=",[147,1703,673],{"class":225},[147,1705,1706],{"class":157},"save",[147,1708,684],{"class":225},[147,1710,1711],{"class":180}," dir=",[147,1713,673],{"class":225},[147,1715,1716],{"class":157},"output_dir",[147,1718,684],{"class":225},[147,1720,1721],{"class":180}," tls=",[147,1723,1724],{"class":225},"{bool",[147,1726,1727],{"class":157},"(cert)",[147,1729,684],{"class":225},[147,1731,670],{"class":180},[147,1733,184],{"class":157},[147,1735,1736],{"class":149,"line":591},[147,1737,171],{"emptyLinePlaceholder":170},[147,1739,1740],{"class":149,"line":612},[147,1741,171],{"emptyLinePlaceholder":170},[147,1743,1744,1746,1749,1752,1755],{"class":149,"line":641},[147,1745,43],{"class":153},[147,1747,1748],{"class":225}," __name__",[147,1750,1751],{"class":153}," ==",[147,1753,1754],{"class":180}," \"__main__\"",[147,1756,359],{"class":157},[147,1758,1759],{"class":149,"line":661},[147,1760,1761],{"class":157},"    cli()\n",[84,1763],{"name":1764},"dep-flow",[10,1766,1767],{},"How it works:",[62,1769,1770,1793,1802,1818,1828,1841],{},[65,1771,1772,1775,1776,318,1779,17,1782,1785,1786,1789,1790,1792],{},[46,1773,1774],{},"Rules are data."," ",[14,1777,1778],{},"Exclusive",[14,1780,1781],{},"Requires",[14,1783,1784],{},"OnlyWith"," are small frozen dataclasses with a ",[14,1787,1788],{},"check(ctx)"," method returning an error message or ",[14,1791,131],{},". The command's rules are listed in one decorator, readable at a glance next to the options they govern.",[65,1794,1795,1801],{},[46,1796,1797,1800],{},[14,1798,1799],{},"enforce"," runs after parsing and conversion, before the body."," Every value is already typed, so rules can inspect them, and the body can assume all rules hold.",[65,1803,1804,1775,1807,1810,1811,1813,1814,1817],{},[46,1805,1806],{},"Messages use the real flag names.",[14,1808,1809],{},"flag()"," looks up the option's first spelling (",[14,1812,16],{},", not the parameter name ",[14,1815,1816],{},"as_json","), so errors match what users type.",[65,1819,1820,1823,1824,1827],{},[46,1821,1822],{},"All violations are reported together."," Collecting messages from every rule and raising one ",[14,1825,1826],{},"UsageError"," saves users the fix-one-rerun loop.",[65,1829,1830,1836,1837,55],{},[46,1831,1832,1835],{},[14,1833,1834],{},"ctx.fail()"," produces the standard format",": usage line, \"Error: ...\", exit status 2 — the same as Click's own errors, as described in ",[51,1838,1840],{"href":1839},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fchoosing-exit-codes-for-cli-tools\u002F","choosing exit codes for CLI tools",[65,1842,1843,1846,1847,201,1849,1851,1852,201,1854,1856],{},[46,1844,1845],{},"Symmetric rules are listed twice."," \"",[14,1848,24],{},[14,1850,28],{},"\" and \"",[14,1853,28],{},[14,1855,24],{},"\" are separate rules, so each direction gets a precise message.",[1858,1859,1861],"h3",{"id":1860},"in-typer","In Typer",[10,1863,1864,1865,1868,1869,1872],{},"Typer commands can use the same rules by taking a ",[14,1866,1867],{},"typer.Context"," parameter and calling ",[14,1870,1871],{},"check_rules"," as the first line of the body:",[138,1874,1876],{"className":140,"code":1875,"language":142,"meta":143,"style":143},"import typer\n\nfrom mytool.rules import Exclusive, Requires, check_rules\n\napp = typer.Typer()\n\n\n@app.command()\ndef report(\n    ctx: typer.Context,\n    as_json: bool = typer.Option(False, \"--json\"),\n    as_csv: bool = typer.Option(False, \"--csv\"),\n    cert: str | None = typer.Option(None, \"--cert\"),\n    key: str | None = typer.Option(None, \"--key\", envvar=\"MYTOOL_KEY\"),\n) -> None:\n    check_rules(ctx, Exclusive((\"as_json\", \"as_csv\")), Requires(\"cert\", \"key\"), Requires(\"key\", \"cert\"))\n    ...\n",[14,1877,1878,1885,1889,1900,1904,1914,1918,1922,1929,1937,1942,1962,1981,2004,2035,2043,2075],{"__ignoreMap":143},[147,1879,1880,1882],{"class":149,"line":150},[147,1881,161],{"class":153},[147,1883,1884],{"class":157}," typer\n",[147,1886,1887],{"class":149,"line":167},[147,1888,171],{"emptyLinePlaceholder":170},[147,1890,1891,1893,1895,1897],{"class":149,"line":174},[147,1892,154],{"class":153},[147,1894,1259],{"class":157},[147,1896,161],{"class":153},[147,1898,1899],{"class":157}," Exclusive, Requires, check_rules\n",[147,1901,1902],{"class":149,"line":187},[147,1903,171],{"emptyLinePlaceholder":170},[147,1905,1906,1909,1911],{"class":149,"line":246},[147,1907,1908],{"class":157},"app ",[147,1910,391],{"class":153},[147,1912,1913],{"class":157}," typer.Typer()\n",[147,1915,1916],{"class":149,"line":259},[147,1917,171],{"emptyLinePlaceholder":170},[147,1919,1920],{"class":149,"line":272},[147,1921,171],{"emptyLinePlaceholder":170},[147,1923,1924,1927],{"class":149,"line":285},[147,1925,1926],{"class":343},"@app.command",[147,1928,1280],{"class":157},[147,1930,1931,1933,1935],{"class":149,"line":290},[147,1932,340],{"class":153},[147,1934,1596],{"class":343},[147,1936,1529],{"class":157},[147,1938,1939],{"class":149,"line":298},[147,1940,1941],{"class":157},"    ctx: typer.Context,\n",[147,1943,1944,1947,1949,1951,1954,1956,1958,1960],{"class":149,"line":303},[147,1945,1946],{"class":157},"    as_json: ",[147,1948,356],{"class":225},[147,1950,309],{"class":153},[147,1952,1953],{"class":157}," typer.Option(",[147,1955,135],{"class":225},[147,1957,318],{"class":157},[147,1959,1324],{"class":180},[147,1961,1559],{"class":157},[147,1963,1964,1967,1969,1971,1973,1975,1977,1979],{"class":149,"line":327},[147,1965,1966],{"class":157},"    as_csv: ",[147,1968,356],{"class":225},[147,1970,309],{"class":153},[147,1972,1953],{"class":157},[147,1974,135],{"class":225},[147,1976,318],{"class":157},[147,1978,1359],{"class":180},[147,1980,1559],{"class":157},[147,1982,1983,1986,1988,1990,1992,1994,1996,1998,2000,2002],{"class":149,"line":332},[147,1984,1985],{"class":157},"    cert: ",[147,1987,350],{"class":225},[147,1989,605],{"class":153},[147,1991,412],{"class":225},[147,1993,309],{"class":153},[147,1995,1953],{"class":157},[147,1997,131],{"class":225},[147,1999,318],{"class":157},[147,2001,1456],{"class":180},[147,2003,1559],{"class":157},[147,2005,2006,2009,2011,2013,2015,2017,2019,2021,2023,2025,2027,2029,2031,2033],{"class":149,"line":337},[147,2007,2008],{"class":157},"    key: ",[147,2010,350],{"class":225},[147,2012,605],{"class":153},[147,2014,412],{"class":225},[147,2016,309],{"class":153},[147,2018,1953],{"class":157},[147,2020,131],{"class":225},[147,2022,318],{"class":157},[147,2024,1488],{"class":180},[147,2026,318],{"class":157},[147,2028,1505],{"class":548},[147,2030,391],{"class":153},[147,2032,1510],{"class":180},[147,2034,1559],{"class":157},[147,2036,2037,2039,2041],{"class":149,"line":362},[147,2038,353],{"class":157},[147,2040,131],{"class":225},[147,2042,359],{"class":157},[147,2044,2045,2048,2050,2052,2054,2057,2059,2061,2063,2066,2068,2070,2072],{"class":149,"line":368},[147,2046,2047],{"class":157},"    check_rules(ctx, Exclusive((",[147,2049,1329],{"class":180},[147,2051,318],{"class":157},[147,2053,1364],{"class":180},[147,2055,2056],{"class":157},")), Requires(",[147,2058,1567],{"class":180},[147,2060,318],{"class":157},[147,2062,181],{"class":180},[147,2064,2065],{"class":157},"), Requires(",[147,2067,181],{"class":180},[147,2069,318],{"class":157},[147,2071,1567],{"class":180},[147,2073,2074],{"class":157},"))\n",[147,2076,2077],{"class":149,"line":373},[147,2078,2079],{"class":225},"    ...\n",[10,2081,2082,2083,2085,2086,2089,2090,2093,2094,2097,2098,2101,2102,17,2105,2107,2108,2110],{},"Use the explicit call rather than the ",[14,2084,1799],{}," decorator with Typer. Recent Typer releases ship their own vendored copy of Click, so ",[14,2087,2088],{},"click.get_current_context()"," from the standalone ",[14,2091,2092],{},"click"," package does not see Typer's context, and Typer's ",[14,2095,2096],{},"ParameterSource"," enum is a different class. That is also why ",[14,2099,2100],{},"given()"," compares sources ",[46,2103,2104],{},"by name",[14,2106,1871],{}," raises through ",[14,2109,1834],{},", which uses whichever Click the context belongs to — the same rules module then works unchanged in both frameworks.",[1858,2112,2114],{"id":2113},"value-relationships","Value relationships",[10,2116,2117,2118,2121],{},"For rules about values — a date range, a minimum that must not exceed a maximum — check in the command body right after the decorator has run, and raise ",[14,2119,2120],{},"click.BadParameter(message, param_hint=\"--until\")"," so the error names the option. Keeping these few lines at the top of the body, next to the generic rules in the decorator, keeps all validation visible in one place.",[57,2123,2125],{"id":2124},"ux-considerations","UX considerations",[84,2127],{"name":2128},"dep-terminal",[62,2130,2131,2142,2151,2160],{},[65,2132,2133,2136,2137,17,2139,2141],{},[46,2134,2135],{},"Never resolve a conflict silently."," If the user typed both ",[14,2138,16],{},[14,2140,20],{},", they meant something by each; an error is kinder than a guess.",[65,2143,2144,2147,2148,2150],{},[46,2145,2146],{},"State the rule in help text too."," \"(requires --save)\" in the help for ",[14,2149,32],{}," teaches the rule before anyone breaks it.",[65,2152,2153,1775,2156,2159],{},[46,2154,2155],{},"Prefer a single option when choices are exclusive.",[14,2157,2158],{},"--format json|csv|table"," makes the conflict impossible, and is often better design than exclusive flags — keep flags as shortcuts if users like them.",[65,2161,2162,2165,2166,2169],{},[46,2163,2164],{},"Mind environment values."," Because environment variables count as \"given\", a stray ",[14,2167,2168],{},"MYTOOL_KEY"," in someone's shell can satisfy or trigger rules. Mentioning the source in errors (\"--key (from MYTOOL_KEY)\") helps in complex setups.",[57,2171,2173],{"id":2172},"testing-the-behaviour","Testing the behaviour",[10,2175,2176],{},"Every rule needs a passing and a failing case, and the environment case deserves its own test:",[138,2178,2180],{"className":140,"code":2179,"language":142,"meta":143,"style":143},"# tests\u002Ftest_rules.py\nimport pytest\nfrom click.testing import CliRunner\n\nfrom mytool.cli import cli\n\nrunner = CliRunner()\n\n\ndef run(*args, env=None):\n    return runner.invoke(cli, [\"report\", *args], env=env or {\"MYTOOL_KEY\": \"\"})\n\n\ndef test_defaults_are_fine():\n    assert run().exit_code == 0\n\n\n@pytest.mark.parametrize(\"args, message\", [\n    ([\"--json\", \"--csv\"], \"--json cannot be used together with --csv.\"),\n    ([\"--output-dir\", \"out\"], \"--output-dir is only allowed with --save.\"),\n    ([\"--cert\", \"c.pem\"], \"--cert requires --key.\"),\n    ([\"--key\", \"k.pem\"], \"--key requires --cert.\"),\n])\ndef test_rule_violations_are_usage_errors(args, message):\n    result = run(*args)\n    assert result.exit_code == 2\n    assert message in result.output\n\n\ndef test_valid_combinations():\n    assert run(\"--save\", \"--output-dir\", \"out\", \"--json\").exit_code == 0\n    assert run(\"--cert\", \"c.pem\", \"--key\", \"k.pem\").exit_code == 0\n\n\ndef test_environment_counts_as_given():\n    assert run(\"--cert\", \"c.pem\", env={\"MYTOOL_KEY\": \"k.pem\"}).exit_code == 0\n\n\ndef test_all_problems_reported_together():\n    result = run(\"--json\", \"--csv\", \"--cert\", \"c.pem\")\n    assert \"--json cannot\" in result.output and \"--cert requires\" in result.output\n",[14,2181,2182,2187,2194,2206,2210,2222,2226,2236,2240,2244,2265,2306,2310,2314,2324,2337,2341,2345,2358,2377,2395,2413,2431,2436,2446,2461,2473,2485,2489,2493,2502,2529,2555,2559,2563,2572,2605,2609,2613,2622,2646],{"__ignoreMap":143},[147,2183,2184],{"class":149,"line":150},[147,2185,2186],{"class":190},"# tests\u002Ftest_rules.py\n",[147,2188,2189,2191],{"class":149,"line":167},[147,2190,161],{"class":153},[147,2192,2193],{"class":157}," pytest\n",[147,2195,2196,2198,2201,2203],{"class":149,"line":174},[147,2197,154],{"class":153},[147,2199,2200],{"class":157}," click.testing ",[147,2202,161],{"class":153},[147,2204,2205],{"class":157}," CliRunner\n",[147,2207,2208],{"class":149,"line":187},[147,2209,171],{"emptyLinePlaceholder":170},[147,2211,2212,2214,2217,2219],{"class":149,"line":246},[147,2213,154],{"class":153},[147,2215,2216],{"class":157}," mytool.cli ",[147,2218,161],{"class":153},[147,2220,2221],{"class":157}," cli\n",[147,2223,2224],{"class":149,"line":259},[147,2225,171],{"emptyLinePlaceholder":170},[147,2227,2228,2231,2233],{"class":149,"line":272},[147,2229,2230],{"class":157},"runner ",[147,2232,391],{"class":153},[147,2234,2235],{"class":157}," CliRunner()\n",[147,2237,2238],{"class":149,"line":285},[147,2239,171],{"emptyLinePlaceholder":170},[147,2241,2242],{"class":149,"line":290},[147,2243,171],{"emptyLinePlaceholder":170},[147,2245,2246,2248,2251,2253,2255,2258,2260,2262],{"class":149,"line":298},[147,2247,340],{"class":153},[147,2249,2250],{"class":343}," run",[147,2252,545],{"class":157},[147,2254,1014],{"class":153},[147,2256,2257],{"class":157},"args, env",[147,2259,391],{"class":153},[147,2261,131],{"class":225},[147,2263,2264],{"class":157},"):\n",[147,2266,2267,2269,2272,2275,2277,2279,2282,2285,2287,2290,2293,2295,2297,2300,2303],{"class":149,"line":303},[147,2268,400],{"class":153},[147,2270,2271],{"class":157}," runner.invoke(cli, [",[147,2273,2274],{"class":180},"\"report\"",[147,2276,318],{"class":157},[147,2278,1014],{"class":153},[147,2280,2281],{"class":157},"args], ",[147,2283,2284],{"class":548},"env",[147,2286,391],{"class":153},[147,2288,2289],{"class":157},"env ",[147,2291,2292],{"class":153},"or",[147,2294,312],{"class":157},[147,2296,1510],{"class":180},[147,2298,2299],{"class":157},": ",[147,2301,2302],{"class":180},"\"\"",[147,2304,2305],{"class":157},"})\n",[147,2307,2308],{"class":149,"line":327},[147,2309,171],{"emptyLinePlaceholder":170},[147,2311,2312],{"class":149,"line":332},[147,2313,171],{"emptyLinePlaceholder":170},[147,2315,2316,2318,2321],{"class":149,"line":337},[147,2317,340],{"class":153},[147,2319,2320],{"class":343}," test_defaults_are_fine",[147,2322,2323],{"class":157},"():\n",[147,2325,2326,2329,2332,2334],{"class":149,"line":362},[147,2327,2328],{"class":153},"    assert",[147,2330,2331],{"class":157}," run().exit_code ",[147,2333,485],{"class":153},[147,2335,2336],{"class":225}," 0\n",[147,2338,2339],{"class":149,"line":368},[147,2340,171],{"emptyLinePlaceholder":170},[147,2342,2343],{"class":149,"line":373},[147,2344,171],{"emptyLinePlaceholder":170},[147,2346,2347,2350,2352,2355],{"class":149,"line":379},[147,2348,2349],{"class":343},"@pytest.mark.parametrize",[147,2351,545],{"class":157},[147,2353,2354],{"class":180},"\"args, message\"",[147,2356,2357],{"class":157},", [\n",[147,2359,2360,2363,2365,2367,2369,2372,2375],{"class":149,"line":385},[147,2361,2362],{"class":157},"    ([",[147,2364,1324],{"class":180},[147,2366,318],{"class":157},[147,2368,1359],{"class":180},[147,2370,2371],{"class":157},"], ",[147,2373,2374],{"class":180},"\"--json cannot be used together with --csv.\"",[147,2376,1559],{"class":157},[147,2378,2379,2381,2383,2385,2388,2390,2393],{"class":149,"line":397},[147,2380,2362],{"class":157},[147,2382,1420],{"class":180},[147,2384,318],{"class":157},[147,2386,2387],{"class":180},"\"out\"",[147,2389,2371],{"class":157},[147,2391,2392],{"class":180},"\"--output-dir is only allowed with --save.\"",[147,2394,1559],{"class":157},[147,2396,2397,2399,2401,2403,2406,2408,2411],{"class":149,"line":427},[147,2398,2362],{"class":157},[147,2400,1456],{"class":180},[147,2402,318],{"class":157},[147,2404,2405],{"class":180},"\"c.pem\"",[147,2407,2371],{"class":157},[147,2409,2410],{"class":180},"\"--cert requires --key.\"",[147,2412,1559],{"class":157},[147,2414,2415,2417,2419,2421,2424,2426,2429],{"class":149,"line":432},[147,2416,2362],{"class":157},[147,2418,1488],{"class":180},[147,2420,318],{"class":157},[147,2422,2423],{"class":180},"\"k.pem\"",[147,2425,2371],{"class":157},[147,2427,2428],{"class":180},"\"--key requires --cert.\"",[147,2430,1559],{"class":157},[147,2432,2433],{"class":149,"line":437},[147,2434,2435],{"class":157},"])\n",[147,2437,2438,2440,2443],{"class":149,"line":455},[147,2439,340],{"class":153},[147,2441,2442],{"class":343}," test_rule_violations_are_usage_errors",[147,2444,2445],{"class":157},"(args, message):\n",[147,2447,2448,2451,2453,2456,2458],{"class":149,"line":491},[147,2449,2450],{"class":157},"    result ",[147,2452,391],{"class":153},[147,2454,2455],{"class":157}," run(",[147,2457,1014],{"class":153},[147,2459,2460],{"class":157},"args)\n",[147,2462,2463,2465,2468,2470],{"class":149,"line":529},[147,2464,2328],{"class":153},[147,2466,2467],{"class":157}," result.exit_code ",[147,2469,485],{"class":153},[147,2471,2472],{"class":225}," 2\n",[147,2474,2475,2477,2480,2482],{"class":149,"line":534},[147,2476,2328],{"class":153},[147,2478,2479],{"class":157}," message ",[147,2481,421],{"class":153},[147,2483,2484],{"class":157}," result.output\n",[147,2486,2487],{"class":149,"line":539},[147,2488,171],{"emptyLinePlaceholder":170},[147,2490,2491],{"class":149,"line":559},[147,2492,171],{"emptyLinePlaceholder":170},[147,2494,2495,2497,2500],{"class":149,"line":570},[147,2496,340],{"class":153},[147,2498,2499],{"class":343}," test_valid_combinations",[147,2501,2323],{"class":157},[147,2503,2504,2506,2508,2510,2512,2514,2516,2518,2520,2522,2525,2527],{"class":149,"line":586},[147,2505,2328],{"class":153},[147,2507,2455],{"class":157},[147,2509,1392],{"class":180},[147,2511,318],{"class":157},[147,2513,1420],{"class":180},[147,2515,318],{"class":157},[147,2517,2387],{"class":180},[147,2519,318],{"class":157},[147,2521,1324],{"class":180},[147,2523,2524],{"class":157},").exit_code ",[147,2526,485],{"class":153},[147,2528,2336],{"class":225},[147,2530,2531,2533,2535,2537,2539,2541,2543,2545,2547,2549,2551,2553],{"class":149,"line":591},[147,2532,2328],{"class":153},[147,2534,2455],{"class":157},[147,2536,1456],{"class":180},[147,2538,318],{"class":157},[147,2540,2405],{"class":180},[147,2542,318],{"class":157},[147,2544,1488],{"class":180},[147,2546,318],{"class":157},[147,2548,2423],{"class":180},[147,2550,2524],{"class":157},[147,2552,485],{"class":153},[147,2554,2336],{"class":225},[147,2556,2557],{"class":149,"line":612},[147,2558,171],{"emptyLinePlaceholder":170},[147,2560,2561],{"class":149,"line":641},[147,2562,171],{"emptyLinePlaceholder":170},[147,2564,2565,2567,2570],{"class":149,"line":661},[147,2566,340],{"class":153},[147,2568,2569],{"class":343}," test_environment_counts_as_given",[147,2571,2323],{"class":157},[147,2573,2574,2576,2578,2580,2582,2584,2586,2588,2590,2592,2594,2596,2598,2601,2603],{"class":149,"line":704},[147,2575,2328],{"class":153},[147,2577,2455],{"class":157},[147,2579,1456],{"class":180},[147,2581,318],{"class":157},[147,2583,2405],{"class":180},[147,2585,318],{"class":157},[147,2587,2284],{"class":548},[147,2589,391],{"class":153},[147,2591,673],{"class":157},[147,2593,1510],{"class":180},[147,2595,2299],{"class":157},[147,2597,2423],{"class":180},[147,2599,2600],{"class":157},"}).exit_code ",[147,2602,485],{"class":153},[147,2604,2336],{"class":225},[147,2606,2607],{"class":149,"line":713},[147,2608,171],{"emptyLinePlaceholder":170},[147,2610,2611],{"class":149,"line":718},[147,2612,171],{"emptyLinePlaceholder":170},[147,2614,2615,2617,2620],{"class":149,"line":723},[147,2616,340],{"class":153},[147,2618,2619],{"class":343}," test_all_problems_reported_together",[147,2621,2323],{"class":157},[147,2623,2624,2626,2628,2630,2632,2634,2636,2638,2640,2642,2644],{"class":149,"line":738},[147,2625,2450],{"class":157},[147,2627,391],{"class":153},[147,2629,2455],{"class":157},[147,2631,1324],{"class":180},[147,2633,318],{"class":157},[147,2635,1359],{"class":180},[147,2637,318],{"class":157},[147,2639,1456],{"class":180},[147,2641,318],{"class":157},[147,2643,2405],{"class":180},[147,2645,184],{"class":157},[147,2647,2648,2650,2653,2656,2659,2661,2664,2666],{"class":149,"line":748},[147,2649,2328],{"class":153},[147,2651,2652],{"class":180}," \"--json cannot\"",[147,2654,2655],{"class":153}," in",[147,2657,2658],{"class":157}," result.output ",[147,2660,801],{"class":153},[147,2662,2663],{"class":180}," \"--cert requires\"",[147,2665,2655],{"class":153},[147,2667,2484],{"class":157},[10,2669,2670,2671,55],{},"The parametrised test doubles as documentation of every rule and its exact message. The environment test proves that parameter sources are consulted correctly, and the last test pins the \"report everything at once\" behaviour. More on structuring such tests is in ",[51,2672,2674],{"href":2673},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Ftesting-click-commands-with-clirunner\u002F","testing Click commands with CliRunner",[57,2676,2678],{"id":2677},"conclusion","Conclusion",[10,2680,2681,2682,2685],{},"Option relationships are part of a command's interface and deserve the same care as the options themselves. Express conflicts, requirements and only-with rules as small declarative objects, check them all in one decorator after parsing, use ",[14,2683,2684],{},"get_parameter_source"," so defaults never count as user input while environment values do, report every violation together as a standard usage error with the real flag names, and test each rule both ways. Commands then fail clearly on contradictory input and never silently ignore something the user typed.",[57,2687,2689],{"id":2688},"frequently-asked-questions","Frequently asked questions",[1858,2691,2693],{"id":2692},"why-not-use-a-third-party-package-like-click-option-group","Why not use a third-party package like click-option-group?",[10,2695,2696,2697,2700],{},"Packages such as ",[14,2698,2699],{},"click-option-group"," provide grouped and mutually exclusive options with good help output, and are a fine choice for Click-only projects. The small rule set here works with both Click and Typer, handles parameter sources explicitly, and keeps the rules visible next to the command.",[1858,2702,2704],{"id":2703},"can-rules-depend-on-option-values-rather-than-presence","Can rules depend on option values rather than presence?",[10,2706,2707,2709,2710,2713,2714,2717,2718,2721,2722,2725],{},[14,2708,1784],{}," already checks a flag's value. For richer conditions — \"",[14,2711,2712],{},"--replicas"," above 10 requires ",[14,2715,2716],{},"--force","\" — add a rule class whose ",[14,2719,2720],{},"check"," reads ",[14,2723,2724],{},"ctx.params",", or write the check directly in the command body.",[1858,2727,2729],{"id":2728},"should-config-file-values-count-as-given","Should config-file values count as given?",[10,2731,2732,2733,2736,2737,2740,2741,2744,2745,2747,2748,55],{},"If you load a config file into ",[14,2734,2735],{},"ctx.default_map",", Click reports those values as ",[14,2738,2739],{},"DEFAULT_MAP",". Whether they should satisfy \"requires\" rules is a design choice; usually they should, so add ",[14,2742,2743],{},"ParameterSource.DEFAULT_MAP"," to the ",[14,2746,113],{}," check. See ",[51,2749,2751],{"href":2750},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Fconfig-precedence-flags-env-files-defaults\u002F","config precedence: flags, env, files and defaults",[1858,2753,2755,2756,2759],{"id":2754},"how-do-i-show-these-rules-in-help","How do I show these rules in ",[14,2757,2758],{},"--help","?",[10,2761,2762,2763,55],{},"Mention them in each option's help text, and consider an epilog listing the rules for complex commands, as covered in ",[51,2764,2766],{"href":2765},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fadding-examples-and-epilogs-to-help-output\u002F","adding examples and epilogs to help output",[57,2768,2770],{"id":2769},"related","Related",[62,2772,2773,2779,2785,2791,2796],{},[65,2774,2775,2776],{},"Up: ",[51,2777,2778],{"href":53},"Advanced argument validation strategies",[65,2780,2781],{},[51,2782,2784],{"href":2783},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fwriting-custom-click-parameter-types\u002F","Writing custom Click parameter types",[65,2786,2787],{},[51,2788,2790],{"href":2789},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-file-and-directory-paths-in-clis\u002F","Validating file and directory paths in CLIs",[65,2792,2793],{},[51,2794,2795],{"href":77},"Mutually exclusive options in argparse",[65,2797,2798],{},[51,2799,2801],{"href":2800},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions\u002Fglobal-options-vs-per-command-options\u002F","Global options vs per-command options",[2803,2804,2805],"style",{},"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 .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}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 .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}",{"title":143,"searchDepth":167,"depth":167,"links":2807},[2808,2809,2810,2811,2815,2816,2817,2818,2825],{"id":59,"depth":167,"text":60},{"id":81,"depth":167,"text":82},{"id":117,"depth":167,"text":118},{"id":207,"depth":167,"text":208,"children":2812},[2813,2814],{"id":1860,"depth":174,"text":1861},{"id":2113,"depth":174,"text":2114},{"id":2124,"depth":167,"text":2125},{"id":2172,"depth":167,"text":2173},{"id":2677,"depth":167,"text":2678},{"id":2688,"depth":167,"text":2689,"children":2819},[2820,2821,2822,2823],{"id":2692,"depth":174,"text":2693},{"id":2703,"depth":174,"text":2704},{"id":2728,"depth":174,"text":2729},{"id":2754,"depth":174,"text":2824},"How do I show these rules in --help?",{"id":2769,"depth":167,"text":2770},"2026-09-18","Enforce option relationships in Click and Typer: conflicts, requires, only-with rules declared as data, parameter sources for defaults vs flags, and tests.","intermediate",false,"md",{},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-dependent-and-conflicting-options",{"title":5,"description":2827},"advanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-dependent-and-conflicting-options\u002Findex",[2092,2836,2837,2838],"validation","options","cli-design","wjngP27xP9qkJMiG9thlA3Kf9YClYmY3f8M7Wxx0LfA",[2841,2844,2847,2850,2851,2854,2857,2860,2863,2866,2869,2872,2875,2878,2881,2884,2887,2890,2893,2896,2899,2902,2905,2908,2911,2914,2917,2920,2923,2926,2929,2932,2935,2938,2941,2944,2947,2950,2953,2956,2959,2962,2965,2968,2971,2974,2977,2980,2983,2986,2989,2992,2995,2998,3001,3004,3007,3010,3013,3016,3019,3022,3025,3028,3031,3034,3037,3040,3043,3046,3049,3052,3055,3058,3061,3064,3067,3070,3073,3076,3079,3082,3085,3088,3091,3094,3097,3100,3103,3106,3109,3112,3115,3118,3121,3124,3127,3130,3133,3136,3139,3142,3145,3148,3151,3154,3157,3160,3163,3166,3169,3172,3175,3178,3181,3184,3187,3190,3193,3196,3199,3202,3205,3208,3211,3214,3217,3220,3223,3226,3229,3232,3235,3238,3241,3244,3247,3250,3253,3256,3259,3262,3265,3268,3271,3274,3277,3280,3283,3286,3289,3292,3295,3298,3301,3304,3307,3310,3313,3316,3319,3322,3325,3328,3331,3334,3337,3340,3343,3346,3349,3352,3355,3358,3361,3364,3367,3370,3373,3376,3379,3382,3385],{"path":2842,"title":2843},"\u002Fabout","About Python CLI Toolcraft",{"path":2845,"title":2846},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies","Advanced Argument Validation Strategies",{"path":2848,"title":2849},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fparsing-nested-json-arguments-in-python-clis","Parsing Nested JSON Args in Python CLIs",{"path":2832,"title":5},{"path":2852,"title":2853},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fvalidating-file-and-directory-paths-in-clis","Validating File and Directory Paths in CLIs",{"path":2855,"title":2856},"\u002Fadvanced-input-parsing-user-experience\u002Fadvanced-argument-validation-strategies\u002Fwriting-custom-click-parameter-types","Writing Custom Click Parameter Types",{"path":2858,"title":2859},"\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":2861,"title":2862},"\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":2864,"title":2865},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual","Building Terminal UIs with Textual for Python CLIs",{"path":2867,"title":2868},"\u002Fadvanced-input-parsing-user-experience\u002Fbuilding-terminal-uis-with-textual\u002Ftesting-textual-apps-with-pilot","Testing Textual Apps with Pilot",{"path":2870,"title":2871},"\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":2873,"title":2874},"\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":2876,"title":2877},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation","CLI Help Output and Documentation",{"path":2879,"title":2880},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fversioning-and-deprecating-cli-flags","Versioning and Deprecating CLI Flags",{"path":2882,"title":2883},"\u002Fadvanced-input-parsing-user-experience\u002Fcli-help-output-and-documentation\u002Fwriting-help-text-users-actually-read","Writing Help Text Users Actually Read",{"path":2885,"title":2886},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fadapting-output-to-terminal-width","Adapting Python CLI Output to Terminal Width",{"path":2888,"title":2889},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility\u002Fdetecting-ci-environments-and-non-interactive-shells","Detecting CI Environments and Non-Interactive Shells",{"path":2891,"title":2892},"\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":2894,"title":2895},"\u002Fadvanced-input-parsing-user-experience\u002Fcross-platform-terminal-compatibility","Cross-Platform Terminal Compatibility for Python CLIs",{"path":2897,"title":2898},"\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":2900,"title":2901},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fchoosing-exit-codes-for-cli-tools","Choosing Exit Codes for CLI Tools",{"path":2903,"title":2904},"\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":2906,"title":2907},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Ffriendly-error-messages-and-tracebacks","Friendly Error Messages and Tracebacks",{"path":2909,"title":2910},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes\u002Fhandling-keyboard-interrupt-cleanly","Handling Keyboard Interrupt Cleanly",{"path":2912,"title":2913},"\u002Fadvanced-input-parsing-user-experience\u002Ferror-handling-and-exit-codes","Error Handling and Exit Codes for CLIs",{"path":2915,"title":2916},"\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":2918,"title":2919},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Fconfig-precedence-flags-env-files-defaults","Config Precedence: Flags, Env, Files, Defaults",{"path":2921,"title":2922},"\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":2924,"title":2925},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars","Handling Config Files and Env Vars in CLIs",{"path":2927,"title":2928},"\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":2930,"title":2931},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Freading-toml-config-with-tomllib","Reading TOML Config with tomllib in Python CLIs",{"path":2933,"title":2934},"\u002Fadvanced-input-parsing-user-experience\u002Fhandling-configuration-files-env-vars\u002Ftyped-settings-with-pydantic-settings","Typed Settings with pydantic-settings in Python CLIs",{"path":2936,"title":2937},"\u002Fadvanced-input-parsing-user-experience","Advanced Input Parsing for Python CLIs",{"path":2939,"title":2940},"\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":2942,"title":2943},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Fbuilding-interactive-prompts-and-menus","Building Interactive Prompts and Menus in Python CLIs",{"path":2945,"title":2946},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich","Interactive Terminal UI with Rich",{"path":2948,"title":2949},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Flive-dashboards-with-rich-live","Live Dashboards with Rich Live in Python CLIs",{"path":2951,"title":2952},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Frendering-tables-and-json-with-rich","Rendering Tables and JSON with Rich",{"path":2954,"title":2955},"\u002Fadvanced-input-parsing-user-experience\u002Finteractive-terminal-ui-with-rich\u002Ftheming-rich-output-consistently","Theming Rich Output Consistently in Python CLIs",{"path":2957,"title":2958},"\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":2960,"title":2961},"\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":2963,"title":2964},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis","Shell Completion for Python CLIs",{"path":2966,"title":2967},"\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":2969,"title":2970},"\u002Fadvanced-input-parsing-user-experience\u002Fshell-completion-for-python-clis\u002Ftesting-shell-completion-in-python-clis","Testing Shell Completion in Python CLIs",{"path":2972,"title":2973},"\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":2975,"title":2976},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Fadding-verbose-and-quiet-logging-flags","Adding Verbose and Quiet Logging Flags",{"path":2978,"title":2979},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps","Structured Logging for CLI Apps",{"path":2981,"title":2982},"\u002Fadvanced-input-parsing-user-experience\u002Fstructured-logging-for-cli-apps\u002Fstructured-json-logging-in-python-clis","Structured JSON Logging in Python CLIs",{"path":2984,"title":2985},"\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":2987,"title":2988},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fdetecting-tty-and-adapting-output","Detecting a TTY and Adapting Output",{"path":2990,"title":2991},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Femitting-json-output-for-scripting","Emitting JSON Output for Scripting",{"path":2993,"title":2994},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Fhandling-broken-pipe-and-sigpipe","Handling Broken Pipe and SIGPIPE",{"path":2996,"title":2997},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes","Working with stdin, stdout and Pipes",{"path":2999,"title":3000},"\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":3002,"title":3003},"\u002Fadvanced-input-parsing-user-experience\u002Fworking-with-stdin-stdout-and-pipes\u002Freading-piped-input-in-python-clis","Reading Piped Input in Python CLIs",{"path":3005,"title":3006},"\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":3008,"title":3009},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fdownloading-files-with-progress-in-python","Downloading Files with Progress in Python CLIs",{"path":3011,"title":3012},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis","Calling HTTP APIs from Python CLIs",{"path":3014,"title":3015},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Foauth-device-flow-login-for-clis","OAuth Device Flow Login for Python CLIs",{"path":3017,"title":3018},"\u002Fcli-runtime-systems-integration\u002Fcalling-http-apis-from-python-clis\u002Fpaginating-api-results-in-a-cli","Paginating API Results in a Python CLI",{"path":3020,"title":3021},"\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":3023,"title":3024},"\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":3026,"title":3027},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis","Concurrency and Async in Python CLIs",{"path":3029,"title":3030},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Fmultiprocessing-for-cpu-bound-cli-tasks","Multiprocessing for CPU-Bound CLI Tasks",{"path":3032,"title":3033},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Fparallelising-cli-work-with-thread-pools","Parallelising CLI Work with Thread Pools",{"path":3035,"title":3036},"\u002Fcli-runtime-systems-integration\u002Fconcurrency-and-async-in-python-clis\u002Frate-limiting-concurrent-requests-in-clis","Rate-Limiting Concurrent Requests in Python CLIs",{"path":3038,"title":3039},"\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":3041,"title":3042},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fcross-platform-paths-with-pathlib","Cross-Platform Paths with pathlib in CLIs",{"path":3044,"title":3045},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Ffile-locking-for-concurrent-cli-runs","File Locking for Concurrent CLI Runs in Python",{"path":3047,"title":3048},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes","Filesystem Paths and Atomic Writes for CLIs",{"path":3050,"title":3051},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fsafe-temporary-files-and-directories","Safe Temporary Files and Directories in CLIs",{"path":3053,"title":3054},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fstoring-app-data-with-platformdirs","Storing CLI App Data with platformdirs",{"path":3056,"title":3057},"\u002Fcli-runtime-systems-integration\u002Ffilesystem-paths-and-atomic-writes\u002Fwriting-files-atomically-in-python-clis","Writing Files Atomically in Python CLIs",{"path":3059,"title":3060},"\u002Fcli-runtime-systems-integration","CLI Runtime & Systems Integration for Python",{"path":3062,"title":3063},"\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":3065,"title":3066},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis\u002Fhandling-sigterm-and-graceful-shutdown","Handling SIGTERM and Graceful Shutdown in CLIs",{"path":3068,"title":3069},"\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":3071,"title":3072},"\u002Fcli-runtime-systems-integration\u002Flong-running-and-watch-mode-clis","Long-Running and Watch-Mode Python CLIs",{"path":3074,"title":3075},"\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":3077,"title":3078},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Favoiding-shell-injection-in-python-clis","Avoiding Shell Injection in Python CLIs",{"path":3080,"title":3081},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fcalling-external-commands-safely-with-subprocess","Calling External Commands Safely with subprocess",{"path":3083,"title":3084},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fhandling-subprocess-timeouts-and-exit-codes","Handling Subprocess Timeouts and Exit Codes",{"path":3086,"title":3087},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis","Running Subprocesses from Python CLIs",{"path":3089,"title":3090},"\u002Fcli-runtime-systems-integration\u002Frunning-subprocesses-from-python-clis\u002Fstreaming-subprocess-output-in-real-time","Streaming Subprocess Output in Real Time",{"path":3092,"title":3093},"\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":3095,"title":3096},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis","Secrets and Credentials in Python CLIs",{"path":3098,"title":3099},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fprompting-for-passwords-securely","Prompting for Passwords Securely in Python CLIs",{"path":3101,"title":3102},"\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":3104,"title":3105},"\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":3107,"title":3108},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fstoring-tokens-with-keyring","Storing CLI Tokens Securely with keyring",{"path":3110,"title":3111},"\u002Fcli-runtime-systems-integration\u002Fsecrets-and-credentials-in-python-clis\u002Fsupporting-multiple-profiles-and-accounts","Supporting Multiple Profiles and Accounts in CLIs",{"path":3113,"title":3114},"\u002F","Python CLI Toolcraft",{"path":3116,"title":3117},"\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":3119,"title":3120},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading","CLI Startup Performance and Lazy Loading",{"path":3122,"title":3123},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Flazy-loading-subcommands-for-faster-startup","Lazy Loading Subcommands for Faster Startup",{"path":3125,"title":3126},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Fprofiling-python-cli-startup-time","Profiling Python CLI Startup Time",{"path":3128,"title":3129},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcli-startup-performance-and-lazy-loading\u002Freducing-cli-dependency-weight","Reducing CLI Dependency Weight",{"path":3131,"title":3132},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fargparse-subparsers-for-subcommands","argparse Subparsers for Subcommands",{"path":3134,"title":3135},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fargparse-vs-click-vs-typer-comparison","argparse vs Click vs Typer Compared",{"path":3137,"title":3138},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse","Command-Line Parsing with argparse",{"path":3140,"title":3141},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fmigrating-from-argparse-to-typer","Migrating from argparse to Typer",{"path":3143,"title":3144},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fmutually-exclusive-options-in-argparse","Mutually Exclusive Options in argparse",{"path":3146,"title":3147},"\u002Fmodern-python-cli-frameworks-architecture\u002Fcommand-line-parsing-with-argparse\u002Fwriting-custom-argparse-actions","Writing Custom argparse Actions in Python",{"path":3149,"title":3150},"\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":3152,"title":3153},"\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":3155,"title":3156},"\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":3158,"title":3159},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions","Designing CLI Interfaces and Conventions in Python",{"path":3161,"title":3162},"\u002Fmodern-python-cli-frameworks-architecture\u002Fdesigning-cli-interfaces-and-conventions\u002Fnaming-commands-and-flags-consistently","Naming Commands and Flags Consistently in Python CLIs",{"path":3164,"title":3165},"\u002Fmodern-python-cli-frameworks-architecture","Python CLI Frameworks and Architecture",{"path":3167,"title":3168},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fdiscovering-plugins-with-entry-points","Discovering Plugins with Entry Points in Python CLIs",{"path":3170,"title":3171},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fhook-based-plugins-with-pluggy","Hook-Based Plugins for Python CLIs with pluggy",{"path":3173,"title":3174},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis","Plugin Architectures for Extensible CLIs",{"path":3176,"title":3177},"\u002Fmodern-python-cli-frameworks-architecture\u002Fplugin-architectures-for-extensible-clis\u002Fversioning-a-plugin-api","Versioning a Plugin API for a Python CLI",{"path":3179,"title":3180},"\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":3182,"title":3183},"\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":3185,"title":3186},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fdependency-injection-patterns-for-cli-commands","Dependency Injection Patterns for CLI Commands",{"path":3188,"title":3189},"\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":3191,"title":3192},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis","Structuring Multi-Command Python CLIs",{"path":3194,"title":3195},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fsharing-common-options-across-commands","Sharing Common Options Across Python CLI Commands",{"path":3197,"title":3198},"\u002Fmodern-python-cli-frameworks-architecture\u002Fstructuring-multi-command-python-clis\u002Fsharing-state-with-click-context-objects","Sharing State with Click Context Objects",{"path":3200,"title":3201},"\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":3203,"title":3204},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications","Testing Python CLI Applications",{"path":3206,"title":3207},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fmeasuring-cli-test-coverage","Measuring CLI Test Coverage",{"path":3209,"title":3210},"\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":3212,"title":3213},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fproperty-based-testing-cli-arguments-with-hypothesis","Property-Based Testing CLI Arguments with Hypothesis",{"path":3215,"title":3216},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Fsnapshot-testing-cli-output","Snapshot Testing CLI Output",{"path":3218,"title":3219},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Ftesting-click-commands-with-clirunner","Testing Click Commands with CliRunner",{"path":3221,"title":3222},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftesting-python-cli-applications\u002Ftesting-interactive-prompts-and-stdin","Testing Interactive Prompts and stdin",{"path":3224,"title":3225},"\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":3227,"title":3228},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fbuilding-dynamic-commands-in-click","Building Dynamic Commands in Click",{"path":3230,"title":3231},"\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":3233,"title":3234},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each","Typer vs Click: When to Use Each",{"path":3236,"title":3237},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Ftyper-callback-functions-explained","Typer callback functions explained",{"path":3239,"title":3240},"\u002Fmodern-python-cli-frameworks-architecture\u002Ftyper-vs-click-when-to-use-each\u002Fusing-annotated-options-in-typer","Using Annotated Options in Typer",{"path":3242,"title":3243},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Fautomating-releases-from-git-tags","Automating Python CLI Releases from Git Tags",{"path":3245,"title":3246},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis\u002Fcaching-uv-dependencies-in-ci","Caching uv Dependencies in CI for Python CLIs",{"path":3248,"title":3249},"\u002Fproject-setup-dependency-management\u002Fci-cd-pipelines-for-python-clis","CI\u002FCD Pipelines for Python CLIs",{"path":3251,"title":3252},"\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":3254,"title":3255},"\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":3257,"title":3258},"\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":3260,"title":3261},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fbuilding-a-cookiecutter-template-for-typer-clis","Building a Cookiecutter Template for Typer CLIs",{"path":3263,"title":3264},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fcopier-vs-cookiecutter-for-cli-templates","Copier vs Cookiecutter for CLI Templates",{"path":3266,"title":3267},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter","CLI Project Scaffolding with Cookiecutter",{"path":3269,"title":3270},"\u002Fproject-setup-dependency-management\u002Fcli-project-scaffolding-with-cookiecutter\u002Fpost-generation-hooks-in-cli-templates","Post-Generation Hooks in Python CLI Templates",{"path":3272,"title":3273},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fbuilding-cross-platform-release-binaries-in-ci","Building Cross-Platform Release Binaries in CI",{"path":3275,"title":3276},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fbundling-a-python-cli-with-pyinstaller","Bundling a Python CLI with PyInstaller",{"path":3278,"title":3279},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fhomebrew-and-scoop-packaging-for-python-clis","Homebrew and Scoop Packaging for Python CLIs",{"path":3281,"title":3282},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries","Distributing CLIs as Standalone Binaries",{"path":3284,"title":3285},"\u002Fproject-setup-dependency-management\u002Fdistributing-clis-as-standalone-binaries\u002Fnuitka-vs-pyinstaller-for-python-clis","Nuitka vs PyInstaller for Python CLI Binaries",{"path":3287,"title":3288},"\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":3290,"title":3291},"\u002Fproject-setup-dependency-management","Project Setup & Dependency Management",{"path":3293,"title":3294},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code\u002Fconfiguring-ruff-for-a-cli-project","Configuring Ruff for a Python CLI Project",{"path":3296,"title":3297},"\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":3299,"title":3300},"\u002Fproject-setup-dependency-management\u002Flinting-and-type-checking-cli-code","Linting and Type-Checking Python CLI Code",{"path":3302,"title":3303},"\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":3305,"title":3306},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fautomating-changelogs-with-conventional-commits","Automating Changelogs with Conventional Commits",{"path":3308,"title":3309},"\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":3311,"title":3312},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fexposing-version-info-and-build-metadata","Exposing Version Info and Build Metadata",{"path":3314,"title":3315},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs","Managing CLI Versioning & Changelogs",{"path":3317,"title":3318},"\u002Fproject-setup-dependency-management\u002Fmanaging-cli-versioning-changelogs\u002Fsemantic-versioning-policy-for-cli-tools","A Semantic Versioning Policy for CLI Tools",{"path":3320,"title":3321},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fbuilding-wheels-and-sdists-for-python-clis","Building Wheels and sdists for Python CLIs",{"path":3323,"title":3324},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fbundling-data-files-with-importlib-resources","Bundling Data Files with importlib.resources in CLIs",{"path":3326,"title":3327},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution","Packaging Python CLIs for Distribution",{"path":3329,"title":3330},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Finstalling-and-distributing-clis-with-pipx","Installing and Distributing CLIs with pipx",{"path":3332,"title":3333},"\u002Fproject-setup-dependency-management\u002Fpackaging-python-clis-for-distribution\u002Fpublishing-a-python-cli-to-pypi","Publishing a Python CLI to PyPI",{"path":3335,"title":3336},"\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":3338,"title":3339},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development","Poetry Workflows for CLI Development",{"path":3341,"title":3342},"\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":3344,"title":3345},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fpoetry-dependency-groups-for-cli-tooling","Poetry Dependency Groups for CLI Tooling",{"path":3347,"title":3348},"\u002Fproject-setup-dependency-management\u002Fpoetry-workflows-for-cli-development\u002Fpoetry-entry-points-and-scripts-for-clis","Poetry Entry Points and Scripts for CLIs",{"path":3350,"title":3351},"\u002Fproject-setup-dependency-management\u002Fpre-commit-hooks-for-cli-projects","Pre-commit Hooks for CLI Projects",{"path":3353,"title":3354},"\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":3356,"title":3357},"\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":3359,"title":3360},"\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":3362,"title":3363},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management","uv for Python CLI Dependency Management",{"path":3365,"title":3366},"\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":3368,"title":3369},"\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":3371,"title":3372},"\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":3374,"title":3375},"\u002Fproject-setup-dependency-management\u002Fuv-for-python-cli-dependency-management\u002Fuv-workspaces-for-multi-package-clis","uv Workspaces for Multi-Package Python CLIs",{"path":3377,"title":3378},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices","Python CLI Env Isolation Best Practices",{"path":3380,"title":3381},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fmanaging-virtual-environments-for-cross-platform-clis","Managing Python CLI Virtual Environments",{"path":3383,"title":3384},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fpinning-the-python-version-for-a-cli","Pinning the Python Version for a CLI",{"path":3386,"title":3387},"\u002Fproject-setup-dependency-management\u002Fvirtual-environments-isolation-best-practices\u002Fsupporting-multiple-python-versions-with-nox","Supporting Multiple Python Versions with nox",1789736905042]