{"id":13532621,"url":"https://github.com/iffy/nim-argparse","last_synced_at":"2026-01-02T02:06:36.116Z","repository":{"id":33509580,"uuid":"152444460","full_name":"iffy/nim-argparse","owner":"iffy","description":"Argument parsing for Nim","archived":false,"fork":false,"pushed_at":"2024-08-16T18:56:53.000Z","size":326,"stargazers_count":122,"open_issues_count":10,"forks_count":8,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-02T19:34:17.319Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Nim","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/iffy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2018-10-10T15:14:58.000Z","updated_at":"2024-10-15T20:59:06.000Z","dependencies_parsed_at":"2024-01-06T12:08:42.990Z","dependency_job_id":"a37c75d1-2725-49ea-8796-d56c9317c88d","html_url":"https://github.com/iffy/nim-argparse","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iffy%2Fnim-argparse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iffy%2Fnim-argparse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iffy%2Fnim-argparse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iffy%2Fnim-argparse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iffy","download_url":"https://codeload.github.com/iffy/nim-argparse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246712928,"owners_count":20821819,"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":[],"created_at":"2024-08-01T07:01:12.344Z","updated_at":"2026-01-02T02:06:36.102Z","avatar_url":"https://github.com/iffy.png","language":"Nim","funding_links":[],"categories":["Development Tools","[Nim](https://nim-lang.org/)"],"sub_categories":["Command-Line Interface Automation","Useful awesome list for Go cli"],"readme":"# argparse\n\n![tests](https://github.com/iffy/nim-argparse/workflows/tests/badge.svg?branch=master)\n\n[Docs](https://www.iffycan.com/nim-argparse/argparse.html)\n\nCommand line argument parsing library.  It generates the parser at compile time so that parsed options have a well-defined type.\n\n# Example\n\nAfter defining your expected arguments with `newParser(...)`, use:\n\n1. `run(...)` to parse and execute any `run:` blocks you've defined.  This will automatically display help text when `-h`/`--help` is used.\n2. `parse(...)` to parse without executing, giving you more control over what happens.\n\nBoth procs will parse the process' command line if no arguments are given.\n\n[See the docs for more info](https://www.iffycan.com/nim-argparse/argparse.html)\n\n## run()\n\n```nim\nimport argparse\n\nvar p = newParser:\n  flag(\"-a\", \"--apple\")\n  flag(\"-b\", help=\"Show a banana\")\n  option(\"-o\", \"--output\", help=\"Output to this file\")\n  command(\"somecommand\"):\n    arg(\"name\")\n    arg(\"others\", nargs = -1)\n    run:\n      echo opts.name\n      echo opts.others\n      echo opts.parentOpts.apple\n      echo opts.parentOpts.b\n      echo opts.parentOpts.output\n      echo opts.parentOpts.output_opt.get()\n\ntry:\n  p.run(@[\"--apple\", \"-o=foo\", \"somecommand\", \"myname\", \"thing1\", \"thing2\"])\nexcept UsageError as e:\n  stderr.writeLine getCurrentExceptionMsg()\n  quit(1)\n```\n\n## parse()\n\n```nim\nimport argparse\n\nvar p = newParser:\n  flag(\"-a\", \"--apple\")\n  flag(\"-b\", help=\"Show a banana\")\n  option(\"-o\", \"--output\", help=\"Output to this file\")\n  arg(\"name\")\n  arg(\"others\", nargs = -1)\n\ntry:\n  var opts = p.parse(@[\"--apple\", \"-o=foo\", \"hi\"])\n  assert opts.apple == true\n  assert opts.b == false\n  assert opts.output == \"foo\"\n  assert opts.name == \"hi\"\n  assert opts.others == @[]\nexcept ShortCircuit as err:\n  if err.flag == \"argparse_help\":\n    echo err.help\n    quit(1)\nexcept UsageError:\n  stderr.writeLine getCurrentExceptionMsg()\n  quit(1)\n```\n\n# Alternatives\n\nIf `argparse` doesn't suit your needs, consider these alternatives:\n\n- \u003chttps://github.com/c-blake/cligen\u003e\n- \u003chttps://nim-lang.org/docs/parseopt.html\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiffy%2Fnim-argparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiffy%2Fnim-argparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiffy%2Fnim-argparse/lists"}