{"id":26728313,"url":"https://github.com/mohammadreza-alizadeh/argparser","last_synced_at":"2026-04-28T08:39:22.073Z","repository":{"id":284505741,"uuid":"954540502","full_name":"Mohammadreza-Alizadeh/argParser","owner":"Mohammadreza-Alizadeh","description":"a lightweight CLI argument parser with bash","archived":false,"fork":false,"pushed_at":"2025-03-26T07:49:46.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T08:34:09.626Z","etag":null,"topics":["argparse","bash","bash-script","lightweight"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mohammadreza-Alizadeh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-03-25T08:38:51.000Z","updated_at":"2025-03-26T07:49:50.000Z","dependencies_parsed_at":"2025-03-26T08:45:10.862Z","dependency_job_id":null,"html_url":"https://github.com/Mohammadreza-Alizadeh/argParser","commit_stats":null,"previous_names":["mohammadreza-alizadeh/argparser"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mohammadreza-Alizadeh%2FargParser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mohammadreza-Alizadeh%2FargParser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mohammadreza-Alizadeh%2FargParser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mohammadreza-Alizadeh%2FargParser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mohammadreza-Alizadeh","download_url":"https://codeload.github.com/Mohammadreza-Alizadeh/argParser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245932608,"owners_count":20696092,"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":["argparse","bash","bash-script","lightweight"],"created_at":"2025-03-27T22:23:01.647Z","updated_at":"2026-04-28T08:39:22.041Z","avatar_url":"https://github.com/Mohammadreza-Alizadeh.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bash script ArgParser\n\nA reusable, type-aware argument parser for Bash scripts to help you undrestand what a user say\n\ni didn't find a minimal and no-dependency module to use when my scripts need `Argument Parsing`, so here we are.\n\nwith this script you can easily manage your script `argument parsing` logic, just define the option you want to recive from user and let the script handle its validation\nfor anyone wonders, this script is influenced from `python's argparse`    \n## 🧩 Features\n\n- Short \u0026 long flags (e.g. `-f` and `--file`)\n- Required and optional arguments\n- Argument types: `dir`, `number`, `file`\n- Flag safety: avoids consuming other flags as values\n- Auto help generation\n\n\n\n## 🧩 Usage\n\n### 🏗 Define Options\n\nUse the `define_option` function:\n\n```bash\ndefine_option SHORT LONG HAS_ARG DESCRIPTION REQUIRED TYPE DEFAULT\n```\n\n| Parameter     | Description                                      |\n|---------------|--------------------------------------------------|\n| `SHORT`       | Single-letter flag (e.g. `f` for `-f`)           |\n| `LONG`        | Long-form flag (e.g. `file` for `--file`)        |\n| `HAS_ARG`     | `\"yes\"` if flag takes an argument, otherwise `\"no\"` |\n| `DESCRIPTION` | Help description shown to users                 |\n| `REQUIRED`    | `\"required\"` or `\"optional\"`                     |\n| `TYPE`        | `file`, `number`, `dir`, or leave empty for any |\n| `DEFAULT`     | Default value if not provided (optional only)    |\n\n### 🧪 Example\n\n```bash\ndefine_option \"f\" \"file\" \"yes\" \"Input file\" \"required\" \"file\" \"\"\ndefine_option \"n\" \"number\" \"yes\" \"Number of threads\" \"optional\" \"number\" \"21\"\ndefine_option \"d\" \"directory\" \"yes\" \"Input directory\" \"optional\" \"dir\" \"\"\ndefine_option \"s\" \"label\" \"yes\" \"Label name\" \"optional\" \"\" \"\"\n```\n\n---\n\n### 🚀 Parsing and Accessing Values\n\n```bash\nparse_args \"$@\"\necho \"${ARGS[file]}\"\necho \"${ARGS[number]}\"\n```\n\n\nsee the `examples` directory for a in action use of script\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohammadreza-alizadeh%2Fargparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmohammadreza-alizadeh%2Fargparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohammadreza-alizadeh%2Fargparser/lists"}