Skip to content

Latest commit

 

History

History
44 lines (35 loc) · 883 Bytes

README.md

File metadata and controls

44 lines (35 loc) · 883 Bytes

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";

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