https://github.com/aperezdc/cflag
Non-allocating command line flag parser
https://github.com/aperezdc/cflag
cli command-line options parser
Last synced: 7 months ago
JSON representation
Non-allocating command line flag parser
- Host: GitHub
- URL: https://github.com/aperezdc/cflag
- Owner: aperezdc
- License: mit
- Created: 2020-05-31T22:20:06.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-04-27T22:02:09.000Z (9 months ago)
- Last Synced: 2025-04-27T23:18:34.128Z (9 months ago)
- Topics: cli, command-line, options, parser
- Language: C
- Size: 32.2 KB
- Stars: 14
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: COPYING
Awesome Lists containing this project
README
cflag
=====
Installation
------------
With [clib](https://github.com/clibs/clib):
```sh
clib install aperezdc/cflag
```
Example
-------
```c
#include "cflag.h"
int
main(int argc, char **argv)
{
int requests = 5000;
int concurrency = 10;
bool verbose = false;
const char *url = "https://perezdecastro.org";
const struct cflag options[] = {
CFLAG(int, "requests", 'r', &requests,
"Number of total requests"),
CFLAG(int, "concurrency", 0 /* no short option */, &concurrency,
"Number of concurrent requests"),
CFLAG(bool, NULL /* no long option */, 'v', &verbose,
"Verbosely show progress"),
CFLAG(string, "url", 'U', &url,
"Target URL"),
CFLAG_HELP,
CFLAG_END
};
cflag_apply(options, "[options] --url URL", &argc, &argv);
return EXIT_SUCCESS;
}
```