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.
Arwed Mett 1f531a5d62
created subcommands
1 year ago
cmake changed target name 1 year ago
examples changed target name 1 year ago
include/argparse created subcommands 1 year ago
src created subcommands 1 year ago
test created subcommands 1 year ago
.core.yml created subcommands 1 year ago
.gitignore removed rubbish 1 year ago
.valgrind-suppressions fixed valgrind error 1 year ago
CMakeLists.txt created subcommands 1 year ago
Dockerfile added rpm to docker file 1 year ago
LICENSE.txt support duplicate options and added cmake config 1 year ago
README.md added basic readme 1 year ago

README.md

Build Status

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