{"id":22472597,"url":"https://github.com/jcarrano/optparse","last_synced_at":"2025-03-27T16:23:02.011Z","repository":{"id":69250633,"uuid":"215407280","full_name":"jcarrano/optparse","owner":"jcarrano","description":"Command line argument parsing for C.","archived":false,"fork":false,"pushed_at":"2019-10-23T20:02:07.000Z","size":231,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-01T20:11:35.135Z","etag":null,"topics":["c","command-line-parser","getopt","library"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jcarrano.png","metadata":{"files":{"readme":"README.rst","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":"2019-10-15T22:23:11.000Z","updated_at":"2019-10-18T21:03:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"65e36b78-ec66-43a6-9fbe-824343569bef","html_url":"https://github.com/jcarrano/optparse","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcarrano%2Foptparse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcarrano%2Foptparse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcarrano%2Foptparse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcarrano%2Foptparse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcarrano","download_url":"https://codeload.github.com/jcarrano/optparse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245879587,"owners_count":20687406,"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":["c","command-line-parser","getopt","library"],"created_at":"2024-12-06T12:16:31.113Z","updated_at":"2025-03-27T16:23:01.987Z","avatar_url":"https://github.com/jcarrano.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"========\noptparse\n========\n\n------------------------------------\nErgonomic command line parsing for C\n------------------------------------\n\n``optparse`` is *tiny* but *fancy* library for parsing command line arguments\nin C.\n\nFeatures:\n\n- Automatic help/usage generation.\n- Long (\"--long\") and short (\"-s\") option style.\n- Option merging (\"-xaf\" can mean \"-x -a -f\")\n- Option-value merging (\"-upepe\" can mean \"-u pepe\")\n- Use ``--`` to end options (to allow positional arguments starting with dash).\n- No dynamic allocation (unless you want it).\n- Configuration is specified in ``const`` structures \u0026 arrays.\n- 3-clause BSD license.\n- The specification of the options/argument is completely separated from the\n  parsing (meaning other formats could be used).\n\nDocumentation\n=============\n\nDocs are available at https://jcarrano.github.io/optparse/.\n\nType ``make docs`` to build the documentation. Also, look at the header files.\n\nBuilding and installing\n=======================\n\nA makefile is included for convenience - it generates static and dynamic\nlibraries and can also install them.\n\nAll this might not be necessary: the C/H files could just be copied and compiled\ninto the application, or the object file or the static archive.\n\nTyping ``make`` (or ``make all``) will create both a static and a dynamic\nlibrary.\n\n``make install`` installs it into the destination specified by PREFIX (by\ndefault `/usr/local`.\n\n``make tests`` will run the unit tests and record coverage.\n\n\nExamples\n========\n\n.. code:: c\n\n   #include \u003cstdio.h\u003e\n   #include \"optparse.h\"\n\n   enum _rules {\n   \tVERBOSITY,\n   \tSETTABLE,\n   \tINTTHING,\n   \tHELP_OPT,\n   \tARG1,\n   \tN_RULES\n   };\n\n   static const struct opt_rule rules[N_RULES] = {\n   [VERBOSITY] = OPTPARSE_O(COUNT, 'v', \"verbose\",\n   \t\t\t \"Verbosity level (can be given multiple times)\", 0),\n\n   [SETTABLE] = OPTPARSE_O(SET_BOOL, 's', NULL, \"Set a flag 's'\", false),\n\n   [INTTHING] = OPTPARSE_O(INT, 'c',  \"cool\", \"Set an integer\", -10),\n\n   [HELP_OPT] = OPTPARSE_O(DO_HELP, 'h', \"help\", \"Show this help\", 0),\n   /* positionals */\n   [ARG1] = OPTPARSE_P(STR_NOCOPY, \"first-argument\", \"Just store this string\",\n   \t\t    \"hello!\"),\n   };\n\n   static const struct opt_conf cfg = {\n   \t.helpstr = \"Example program\",\n   \t.tune = OPTPARSE_IGNORE_ARGV0,\n   \t.rules = rules,\n   \t.n_rules = N_RULES\n   };\n\n\n   int main(int argc, char *argv[])\n   {\n   \tunion opt_data results[N_RULES];\n   \tint parse_result;\n\n   \tparse_result = optparse_cmd(\u0026cfg, results, argc, argv);\n\n   \tif (parse_result \u003c OPTPARSE_OK) {\n   \t\treturn 1;\n   \t}\n\n   \tprintf(\"Verbosity level is %d\\n\", results[VERBOSITY].d_int);\n   \tprintf(\"Flag 's' is %s\\n\", results[SETTABLE].d_bool? \"on\" : \"off\");\n   \tprintf(\"c = %d (try inputting hex too!)\\n\", results[INTTHING].d_int);\n   \tprintf(\"(Optional) argument value: %s\\n\", results[ARG1].d_cstr);\n\n   \treturn 0;\n   }\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcarrano%2Foptparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcarrano%2Foptparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcarrano%2Foptparse/lists"}