An open API service indexing awesome lists of open source software.

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

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;
}
```