Skip to content

aperezdc/cflag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cflag

Installation

With clib:

clib install aperezdc/cflag

Example

#include "cflag.h"

int
main(int argc, char **argv)
{
    int requests = 5000;
    int concurrency = 10;
    bool verbose = false;
    const char *url = "https://perezdecastro.org";

    static 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] --url URL", &argc, &argv);

    return EXIT_SUCCESS;
}

About

Non-allocating command line flag parser

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages