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