{"id":24994986,"url":"https://github.com/slayers-git/argparse","last_synced_at":"2025-03-29T14:24:05.201Z","repository":{"id":275697477,"uuid":"350985594","full_name":"slayers-git/argparse","owner":"slayers-git","description":"A simple parser for the unix-like command line options","archived":false,"fork":false,"pushed_at":"2022-05-03T14:15:15.000Z","size":76,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-04T04:30:53.013Z","etag":null,"topics":["argparse","args","argument-parser","c","c89","cli","command-line-parser","freestanding","freestanding-environments","lib","option-parser","parser","unix"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/slayers-git.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":"2021-03-24T07:29:28.000Z","updated_at":"2022-05-03T14:04:29.000Z","dependencies_parsed_at":"2025-02-04T04:41:37.933Z","dependency_job_id":null,"html_url":"https://github.com/slayers-git/argparse","commit_stats":null,"previous_names":["slayers-git/argparse"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slayers-git%2Fargparse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slayers-git%2Fargparse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slayers-git%2Fargparse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slayers-git%2Fargparse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slayers-git","download_url":"https://codeload.github.com/slayers-git/argparse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246194351,"owners_count":20738659,"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","args","argument-parser","c","c89","cli","command-line-parser","freestanding","freestanding-environments","lib","option-parser","parser","unix"],"created_at":"2025-02-04T15:25:52.817Z","updated_at":"2025-03-29T14:24:05.172Z","avatar_url":"https://github.com/slayers-git.png","language":"C","readme":"# Introduction\n\nargparse is a simple parser for the command line options, that implements the parser for the standart Unix-like options\n\n## Features\n\n- Merged key-value arguments (i.e objdump -Mintel ...)\n- Values without keys can be ignored, saved or return an error code (i.e gcc *argparse.c* -o argparse ...)\n- Merged short arguments (i.e emerge -uavD ...)\n- Long arguments (i.e emerge --ask --update --verbose ...)\n- Arguments with an optional value\n- No dynamic allocations and copying\n- Can be compiled without stdlib (-ffreestanding)\n\n## Example\n\nNote: a more informative example can be found in example.c\n\n```c\n/* \u003cthis_example\u003e --verbose -cj --move \"/some/where/\" test_project */\n#include \"argparse.h\"\n#include \u003cstdio.h\u003e\n\nstatic char is_verbose = 0;\nstatic char jump = 0;\nstatic char jump_last = 0;\nstatic char should_create = 0;\n\nstatic char * project_name;\n\nstatic char * move_to = NULL;\nstatic char * not_moving = \"not moving anywhere\";\n\nint main (int argc, char ** argv) {\n\t/* argparse does not check if a program had recieved any arguments */\n\tif (argc == 1) {\n\t\treturn 0;\n\t}\n\n\t/* An array, describing the options, that this program accepts */\n\targ_list list = {\n\t\t/* s ,  long opt  ,      handler      ,  value buffer  */ \n\t\t{ 'v', \"verbose\"  , NULL              , \u0026is_verbose    },\n\t\t{ 'c', \"create\"   , NULL              , \u0026should_create },\n\t\t{ 'j', \"jump\"     , NULL              , \u0026jump          },\n\t\t{ 'J', \"jump-last\", NULL              , \u0026jump_last     },\n\t\t{ 'm', \"move\"     , arg_string_handler, \u0026move_to       },\n\t\t{ 0 }\n\t\t/* NOTE */\n\t\t/* 's' stands for \"short option\" here\n\t\t * \"handler\" is a function that accepts a parsed value\n\t\t * of the argument, modifying and writing it into the \n\t\t * value buffer */\n\t};\n\n\t/* return code of the parser */\n\targ_return code;\n\t/* in case of an error, this is going to point to the program's argument\n\t * that was the cause of it */\n\tchar * ptr;\n\n\t/* buffer for the elements, that are not keys */\n\tchar * nk_buffer = NULL;\n\t/* size of the nk_buffer (will be overwritten with the amount of arguments that are not keys) */\n\tsize_t buf_size  = 1;\n\n\t/* parse the program's arguments */\n\tif ((ptr = arg_parse (\u0026argc, \u0026argv, list, \u0026nk_buffer, \u0026buf_size, ARG_PARSE_DEFAULT, \u0026code)) != NULL) {\n\t\tprintf (\"An error occured here: %s\", ptr);\n\t\treturn code;\n\t}\n\n\t/* if the user entered an argument, that does not belong to any key */\n\tif (nk_buffer)\n\t\tproject_name = nk_buffer;\n\n\tif (move_to == NULL)\n\t\tmove_to = not_moving;\n\n\tprintf (\"Name: %s\\nCreate? %i\\nVerbose? %i\\nJump? %i\\nJump-last? %i\\nMove to: %s\\n\", (const char *)project_name, should_create, is_verbose, jump, jump_last, move_to);\n\n\treturn 0;\n}\n\n```\n\n## Installation\n\nTo build and install argparse on \\*Unix systems, in your shell type\n```bash\nmkdir build \u0026\u0026 cd build\\\ncmake .. \u0026\u0026 make \u0026\u0026 sudo make install\n```\n\nTo build examples to `cmake` command add `-DARGPARSE_EXAMPLES=1`; to include error messages via `arg_geterror ()` to `cmake` command add `-DARGPARSE_ERRORS=1`\nNote, that if the library is compiled without error messages, a call to `arg_geterror ()` will always return NULL.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslayers-git%2Fargparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslayers-git%2Fargparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslayers-git%2Fargparse/lists"}