{"id":17158754,"url":"https://github.com/mpeterv/argparse","last_synced_at":"2025-10-07T06:15:04.308Z","repository":{"id":12853367,"uuid":"15529305","full_name":"mpeterv/argparse","owner":"mpeterv","description":"Feature-rich command line parser for Lua","archived":false,"fork":false,"pushed_at":"2020-11-25T07:19:23.000Z","size":636,"stargazers_count":270,"open_issues_count":8,"forks_count":45,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-30T15:08:24.965Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"TaviscaSolutions/frameworks-session","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mpeterv.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-30T14:26:42.000Z","updated_at":"2025-03-14T18:40:13.000Z","dependencies_parsed_at":"2022-09-14T21:10:38.322Z","dependency_job_id":null,"html_url":"https://github.com/mpeterv/argparse","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpeterv%2Fargparse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpeterv%2Fargparse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpeterv%2Fargparse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpeterv%2Fargparse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mpeterv","download_url":"https://codeload.github.com/mpeterv/argparse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247509237,"owners_count":20950232,"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-10-14T22:12:28.478Z","updated_at":"2025-10-07T06:14:59.273Z","avatar_url":"https://github.com/mpeterv.png","language":"Lua","funding_links":[],"categories":["资源","Resources","Lua"],"sub_categories":["Command-line Utilities"],"readme":"# argparse\n\n[![Build Status](https://travis-ci.org/mpeterv/argparse.png?branch=master)](https://travis-ci.org/mpeterv/argparse)\n[![Coverage status](https://codecov.io/gh/mpeterv/argparse/branch/master/graph/badge.svg)](https://codecov.io/gh/mpeterv/argparse)\n\nArgparse is a feature-rich command line parser for Lua inspired by argparse for Python.\n\nArgparse supports positional arguments, options, flags, optional arguments, subcommands and more. Argparse automatically generates usage, help and error messages.\n\n## Contents\n\n* [Example](#example)\n* [Installation](#installation)\n* [Tutorial](#tutorial)\n* [Testing](#testing)\n* [License](#license)\n\n## Example\n\nSimple example:\n\n```lua\n-- script.lua\nlocal argparse = require \"argparse\"\n\nlocal parser = argparse(\"script\", \"An example.\")\nparser:argument(\"input\", \"Input file.\")\nparser:option(\"-o --output\", \"Output file.\", \"a.out\")\nparser:option(\"-I --include\", \"Include locations.\"):count(\"*\")\n\nlocal args = parser:parse()\n```\n\n`args` contents depending on command line arguments:\n\n```bash\n$ lua script.lua foo\n```\n\n```lua\n{\n   input = \"foo\",\n   output = \"a.out\",\n   include = {}\n}\n```\n\n```bash\n$ lua script.lua foo -I/usr/local/include -Isrc -o bar\n```\n\n```lua\n{\n   input = \"foo\",\n   output = \"bar\",\n   include = {\"/usr/local/include\", \"src\"}\n}\n```\n\nError messages depending on command line arguments:\n\n```bash\n$ lua script.lua foo bar\n```\n\n```\nUsage: script [-o \u003coutput\u003e] [-I \u003cinclude\u003e] [-h] \u003cinput\u003e\n\nError: too many arguments\n```\n\n```bash\n$ lua script.lua --help\n```\n\n```\nUsage: script [-o \u003coutput\u003e] [-I \u003cinclude\u003e] [-h] \u003cinput\u003e\n\nAn example. \n\nArguments: \n   input                 Input file.\n\nOptions: \n   -o \u003coutput\u003e, --output \u003coutput\u003e\n                         Output file. (default: a.out)\n   -I \u003cinclude\u003e, --include \u003cinclude\u003e\n                         Include locations.\n   -h, --help            Show this help message and exit.\n```\n\n```bash\n$ lua script.lua foo --outptu=bar\n```\n\n```\nUsage: script [-o \u003coutput\u003e] [-I \u003cinclude\u003e] [-h] \u003cinput\u003e\n\nError: unknown option '--outptu'\nDid you mean '--output'?\n```\n\n## Installation\n\n### Using LuaRocks\n\nInstalling argparse using [LuaRocks](http://luarocks.org) is simple:\n\n```bash\n$ luarocks install argparse\n```\n\n### Without LuaRocks\n\nDownload `src/argparse.lua` file and put it into the directory for Lua libraries or your working directory.\n\n## Tutorial\n\nThe tutorial is available [online](http://argparse.readthedocs.org). If argparse has been installed using LuaRocks 2.1.2 or later, it can be viewed using `luarocks doc argparse` command.\n\nTutorial HTML files can be built using [Sphinx](http://sphinx-doc.org/): `sphinx-build docsrc doc`, the files will be found inside `doc/`.\n\n## Testing\n\nargparse comes with a testing suite located in `spec` directory. [busted](http://olivinelabs.com/busted/) is required for testing, it can be installed using LuaRocks. Run the tests using `busted` command from the argparse folder.\n\n## License\n\nargparse is licensed under the same terms as Lua itself (MIT license).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpeterv%2Fargparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmpeterv%2Fargparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpeterv%2Fargparse/lists"}