{"id":21861331,"url":"https://github.com/seng3694/cli","last_synced_at":"2025-10-10T09:11:17.793Z","repository":{"id":114139344,"uuid":"158618877","full_name":"Seng3694/CLI","owner":"Seng3694","description":"Lightweight CLI Parser","archived":false,"fork":false,"pushed_at":"2019-12-02T10:52:43.000Z","size":11,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-21T20:18:31.643Z","etag":null,"topics":["c","cli","cmake","command-line-interface","command-line-parser"],"latest_commit_sha":null,"homepage":null,"language":"C","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/Seng3694.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":"2018-11-21T23:44:50.000Z","updated_at":"2023-03-25T01:25:35.000Z","dependencies_parsed_at":"2023-06-14T07:00:33.900Z","dependency_job_id":null,"html_url":"https://github.com/Seng3694/CLI","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Seng3694/CLI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seng3694%2FCLI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seng3694%2FCLI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seng3694%2FCLI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seng3694%2FCLI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Seng3694","download_url":"https://codeload.github.com/Seng3694/CLI/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Seng3694%2FCLI/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279003389,"owners_count":26083579,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","cli","cmake","command-line-interface","command-line-parser"],"created_at":"2024-11-28T03:11:14.250Z","updated_at":"2025-10-10T09:11:17.774Z","avatar_url":"https://github.com/Seng3694.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lightweight CLI Parser #\nA CLI parser which is purely written in C and focused to be lightweight. Can be used in C++ applications too.\n\n## How to use ##\n\n```c\n//include the library\n#include \u003ccli.h\u003e\n\nint main(int argc, char** argv)\n{\n    //create the CLI struct\n    //the integral value is the count of arguments you want to define\n    CLI* cli = CLI_Create(3);\n\n    //add 3 arguments:\n    //if you add more arguments than you've defined in the create method, \n    //the program will probably crash. The information is known before \n    //compile time, so make sure to doublecheck.\n    CLI_AddArgument(cli, 'h', ARG_TYPE_COMMAND);\n    CLI_AddArgument(cli, 'v', ARG_TYPE_REQUIRED);\n    CLI_AddArgument(cli, 'r', ARG_TYPE_OPTION);\n    \n    //parse cli args\n    cli_errors errors = CLI_Parse(cli, argc, argv);\n\n    if(errors != 0)\n    {\n        //do your error checking here. As the name indicates, the value \n        //could have more than one error. You can use the \"HAS_FLAG\" macro\n    }\n\n    //if the 'h' command was set\n    if(CLI_OptionSet(cli, 'h'))\n    {\n        printf(\"Some useful help text to print to the user\\n\");\n        return 0;\n    }\n\n    //initialize char* which will point to the value string\n    //you should copy the value if you want to persist it\n    char* value = NULL;\n    if(CLI_TryGetArgument(cli, 'v', \u0026value))\n    {\n        //this section will only be reached if value was set successfully\n        //if 'r' was set, reverse the value\n        if(CLI_OptionSet(cli, 'r'))\n            printf(\"%s\", strrev(value));\n        else\n            printf(\"%s\", value);\n    }\n\n    //clean up allocated commands and value strings\n    CLI_Destroy(cli);\n    return 0;\n}\n```\n\n## Limitations ##\nTo reduce any overhead there are some limitations:\n- Commands do start with a hyphen \"-\"\n- Commands are only one character long \"a\"\n- There are no automatic value conversions\n- The count of commands should be known before compile time =\u003e no dynamic resize. So if you add your fifth command but you only initialized the CLI struct with four, you will experience unexpected behavior.\n\n## Examples ##\n- Example for [C][2] \n- Example for [C++][3]\n- And a few [tests][4]\n\n## Build ##\n\nProject uses [CMake][1] to generate platform and compiler-specific build files.\n\n### Building on Windows (Visual Studio) ###\n1. Clone the repository\n    ```\n    git clone https://github.com/Seng3694/CLI\n    ```\n\n2. Generate the build files (depending on your Visual Studio Version the `cmake` command differs. In this case `\"Visual Studio 15\"` will generate the Visual Studio 2017 project files)\n    ```\n    mkdir bin\n    cd bin\n    cmake -G\"Visual Studio 15\" ../CLI\n    ```\n\n3. You can either open the `.sln` solution file and build the `ALL_BUILD` target or just do it with cmake:\n    ```\n    cmake --build . --config Release\n    ```\n\n## License ##\nThis library is licensed under the MIT License. See [LICENSE][5] for more information.\n\n[1]:http://www.cmake.org/\n[2]:examples/c/main.c\n[3]:examples/cpp/main.cpp\n[4]:tests/main.c\n[5]:LICENSE","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseng3694%2Fcli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseng3694%2Fcli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseng3694%2Fcli/lists"}