{"id":21264671,"url":"https://github.com/mebiusashan/ccli","last_synced_at":"2025-03-15T07:46:23.562Z","repository":{"id":151692600,"uuid":"332683877","full_name":"mebiusashan/ccli","owner":"mebiusashan","description":"Command-line arguments parsing library.","archived":false,"fork":false,"pushed_at":"2021-02-01T10:36:11.000Z","size":41,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-21T22:43:40.398Z","etag":null,"topics":["c","ccli","cli"],"latest_commit_sha":null,"homepage":"","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/mebiusashan.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-01-25T08:48:49.000Z","updated_at":"2024-09-19T16:35:52.000Z","dependencies_parsed_at":"2023-06-04T01:45:30.048Z","dependency_job_id":null,"html_url":"https://github.com/mebiusashan/ccli","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/mebiusashan%2Fccli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mebiusashan%2Fccli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mebiusashan%2Fccli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mebiusashan%2Fccli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mebiusashan","download_url":"https://codeload.github.com/mebiusashan/ccli/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243701309,"owners_count":20333616,"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","ccli","cli"],"created_at":"2024-11-21T05:02:08.087Z","updated_at":"2025-03-15T07:46:23.544Z","avatar_url":"https://github.com/mebiusashan.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ccli\n\nccli - A command line arguments parsing library in C (compatible with C++).\n\n## Description\n\nThis module is inspired by argparse.\n\nArguments parsing is common task in cli program, but traditional `getopt`\nlibraries are not easy to use. This library provides high-level arguments\nparsing solutions.\n\nThe program defines what arguments it requires, and `argparse` will figure\nout how to parse those out of `argc` and `argv`, it also automatically\ngenerates help and usage messages and issues errors when users give the\nprogram invalid arguments.\n\n## Features\n\n - handles both optional and positional arguments\n - produces highly informative usage messages\n - issues errors when given invalid arguments\n - support subcommand\n\nThere are basically three types of options:\n\n - boolean options\n - options with mandatory argument\n - options with optional argument\n\nThere are basically two forms of options:\n\n - short option consist of one dash (`-`) and one alphanumeric character.\n - long option begin with two dashes (`--`) and some alphanumeric characters.\n\nShort options may be bundled, e.g. `-a -b` can be specified as `-ab`.\n\nOptions are case-sensitive.\n\nOptions and non-option arguments can clearly be separated using the `--` option.\n\n## Examples\n\n```c\n#include \u003cstdio.h\u003e\n#include \"ccli.h\"\n\nint force =0;\nint abc = 0;\nfloat cc = 0;\nchar * ss = \"\";\n\nint rootRun ( int argc, const char **argv )\n{\n    printf ( \"%d - %d - %f - %s \\n\", force, abc, cc, ss );\n    printf ( \"%d\\n\",argc );\n    for ( int i=0; i\u003cargc; i++ ) {\n        printf ( \"%s\\n\",argv[i] );\n    }\n    return 0;\n}\n\nint\nmain ( int argc, const char **argv )\n{\n\n    cmd_t root = set_root_cmd ( \"ff\",\"this is help with root command.\",\"this is des.\", \"epilog string\", \u0026rootRun );\n    cmd_t add = set_sub_cmd ( root, \"add\", \"You can add articles, single \\npages, Tweets and categories to the blog\",\"Add content to the blog\", \"add epi\",NULL );\n    cmd_t rm = set_sub_cmd ( root, \"rm\", \"You can delete articles, single pages, Tweets and categories in the blog\",\"Add content to the blog\", \"rm epi\",NULL );\n    cmd_t page = set_sub_cmd ( add, \"page\", \"The path of the markdown file needs to be set. If the - t parameter is set, \\nthe parameter value is used as the article title. \\nIf not set, the file name is used as the article \\ntitle. At the same time, it must be set to the \\nID of the classification to which the chapter belongs\", \"Select action page\",\"add epi\",NULL );\n\n    set_opt ( root, CCLI_OPT_BOOL, 'f', \"force\", \u0026force, \"force option.\" );\n    set_opt ( root, CCLI_OPT_INT, 'n', \"num\", \u0026abc, \"num option.\" );\n    set_opt ( root, CCLI_OPT_FLOAT, 'w', \"width\", \u0026cc, \"width option.\" );\n    set_opt ( root, CCLI_OPT_STRING, 'd', \"des\", \u0026ss, \"description option.\" );\n\n    return ccli_r ( root, argc, argv );\n}\n```\n\n### Test Build\n\n```\ngcc test.c ccli.h ccli.c -o ccli\n```\n\n### Use\n\n```\n$ ./ccli -h\nthis is help with root command.\n\nUsage:\n  ff  [options]\n  ff  [command]\n\nCommands:\n  add  Add content to the blog\n  rm   Add content to the blog\n\nOptions:\n  -f, --force            force option.\n  -n, --num    \u003cint\u003e     num option.\n  -w, --width  \u003cfloat\u003e   width option.\n  -d, --des    \u003cstring\u003e  description option.\n  -h, --help             print help message.\n\nepilog string\n```\n\n```\n$ ./ccli -n5\n0 - 5 - 0.000000 -  \n0\n```\n\n```\n$ ./ccli -f -d=\"this is des.\"\n1 - 0 - 0.000000 - this is des. \n0\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmebiusashan%2Fccli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmebiusashan%2Fccli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmebiusashan%2Fccli/lists"}