You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
3 years ago | |
---|---|---|
cmake | 3 years ago | |
examples | 3 years ago | |
include/argparse | 3 years ago | |
src | 3 years ago | |
test | 3 years ago | |
.core.yml | 3 years ago | |
.gitignore | 3 years ago | |
.valgrind-suppressions | 3 years ago | |
CMakeLists.txt | 3 years ago | |
Dockerfile | 3 years ago | |
LICENSE.txt | 3 years ago | |
README.md | 3 years ago |
README.md
Argparse
Argparse is a small library to parse command line arguments.
Example
The example generates a cli which has the following form:
Usage: custom-flag [options]
Options:
-h, --help Display help message.
-V, --version Display the version.
-c, --custom-flag A custom flag
#include "argparse/argparse.h"
void custom_flag_set(context_t *context) {
//custom flag was set.
bool *flag_set = context->data;
*flag_set = true;
}
int main(int argc, const char **argv) {
command_t command;
command_init(&command, "custom-flag", "0.0.0");
//short name, long-name, description, callback
//-> -c, --custom-flag, A custom flag
command_flag(&command, 'c', "custom-flag", "A custom flag", custom_flag_set);
bool flag_set = false; //this will be passed to the context
command_parse(&command, &flag_set, argc, argv);
command_destroy(&command);
}