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