{"id":26157236,"url":"https://github.com/yaroslaff/argalias","last_synced_at":"2025-04-14T08:53:58.355Z","repository":{"id":277893464,"uuid":"933399303","full_name":"yaroslaff/ArgAlias","owner":"yaroslaff","description":"Argument aliases/abbrevations for python CLI programs (compatible with argparse/click/typer/...)","archived":false,"fork":false,"pushed_at":"2025-02-21T21:37:46.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T22:23:28.259Z","etag":null,"topics":["abbrevation","alias","aliases","argparse","argument-parser","arguments","cli","click","command-line","python","synonym","typer"],"latest_commit_sha":null,"homepage":"https://github.com/yaroslaff/ArgAlias","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yaroslaff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-15T21:23:42.000Z","updated_at":"2025-02-21T21:37:50.000Z","dependencies_parsed_at":"2025-02-16T20:47:03.427Z","dependency_job_id":null,"html_url":"https://github.com/yaroslaff/ArgAlias","commit_stats":null,"previous_names":["yaroslaff/argalias"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaroslaff%2FArgAlias","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaroslaff%2FArgAlias/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaroslaff%2FArgAlias/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaroslaff%2FArgAlias/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yaroslaff","download_url":"https://codeload.github.com/yaroslaff/ArgAlias/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248732483,"owners_count":21152852,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abbrevation","alias","aliases","argparse","argument-parser","arguments","cli","click","command-line","python","synonym","typer"],"created_at":"2025-03-11T09:58:35.470Z","updated_at":"2025-04-14T08:53:58.331Z","avatar_url":"https://github.com/yaroslaff.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ArgAlias\n\n[![Run tests and upload coverage](https://github.com/yaroslaff/ArgAlias/actions/workflows/main.yml/badge.svg)](https://github.com/yaroslaff/ArgAlias/actions/workflows/main.yml) [![codecov](https://codecov.io/gh/yaroslaff/ArgAlias/graph/badge.svg?token=3DUNW2SH81)](https://codecov.io/gh/yaroslaff/ArgAlias)\n\nAliases for arguments in Python CLI utilities (supports argparse, Typer, Click, and similar tools).\n\nThis tool is for those who agree that `p sh X` is shorter then `project show X`.\n\nYou configure which *canonical* CLI arguments you expect, and what aliases are allowed (e.g. for the canonical argument \"show\" good aliases are \"sh\" and \"get\").\n\nIf a canonical name is configured with a prefix, aliases will be resolved only if they follow configured prefix from the first argument.\n\n*Add aliases to your argparse, Click, or Typer project in 10 minutes!*\n\n## Installation\n~~~\npip3 install argalias\n~~~\n\n## How to use\nWhen you add aliases, the first element is either a `str` (the canonical name to which the alias will be resolved to) or a `List[str]` containing prefixes with canonical name.\n\nEach element in the prefix list can be either a simple string (a parameter), `*` (matches any value of parameter) or values separated by the `|` symbol.\n\n~~~python\nfrom argalias import ArgAlias\n\naa = ArgAlias()\n\n# The script expects \"show\" parameter anywhere, and it can be aliased as \"sh\", \"s\" or even \"get\"\naa.alias(\"show\", \"get\", \"sh\", \"s\")\n\n# The script expects \"employee\" as the first parameter, can be aliased as \"emp\" or \"e\" \naa.alias([\"employee\"], \"emp\", \"e\")\n\n# same for \"project\"\naa.alias([\"project\"], \"proj\", \"p\")\n\n# The script expects \"create\" parameter after \"employee\" or \"project\". Can be aliased as \"cr\" or \"c\"\naa.alias([\"employee|project\", \"create\"], \"cr\", \"c\")\n\n# The script expects \"delete\" as the second parameter after any parameter, can be aliased as \"del\" or \"d\"\naa.alias([\"*\", \"delete\"], \"del\", \"d\")\naa.parse()\n# sys.argv now has all aliases resolved, e.g. \"sh\" resolved to \"show\"\nprint(sys.argv)\n\n# now all aliases in sys.argv are resolved and you can do your argparse or click or typer parsing\n~~~\n\nYou can find examples using [argparse](examples/argparse), [Click](examples/click), and [Typer](examples/typer) in [examples/](examples/).\n\nResults:\n~~~\np sh Something -\u003e project show Something\nproject cr Mayhem -\u003e project create Mayhem\n~~~\n\nThese aliases will not be replaced:\n~~~\nsh emp John (\"sh\" resolved to \"show\" but \"emp\" will not be resolved: not a first argument)\nzzz cr xxx (\"cr\" will not be resolved: not after employee or project)\naaa bbb del (\"del\" will not be resolved: prefix is \"aaa\", \"bbb\" - two elements, but \"*\" matches only one element)\n~~~\n\nMight be replaced incorrectly:\n~~~\nproject create sh (You want to create a project named \"sh\", but \"sh\" will be replaced with \"show\" because the alias does not specify any prefix requirements.)\n~~~\n\n## Optional arguments\nOptional arguments can make a problems while checking prefixes, e.g. `script.py -v p del X` will not match `[\"project\"]` prefix, because first argument is \"-v\", not \"p\". Here `skip_flags()` and `nargs()` comes to help.  \n\n~~~python\n# with skip_flags ArgAlias will ignore any unknown arguments starting with \"-\", e.g. \"-v\", or  \"--some-option\"\naa.skip_flags()\n\n# this will ignore --xy 11 22 \naa.nargs('--xy', nargs=2)\n\n# this will ginore --level 123 (default value for nargs is 1)\naa.nargs('--level')\n~~~\n\nSee [argparse_ex1.py](examples/argparse/argparse_ex1.py) for a real example. You do not need to use `skip_flags` or `nargs`:\n1. If you replace parameter anywhere in args (like \"show\" in example above), not using prefix.\n2. If options will go after alias (e.g. `script.py project del X --verbose`)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaroslaff%2Fargalias","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyaroslaff%2Fargalias","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaroslaff%2Fargalias/lists"}