Go to file
Arwed Mett 1f531a5d62
continuous-integration/drone/push Build is passing Szczegóły
created subcommands
2019-05-27 23:31:58 +02:00
cmake changed target name 2019-04-02 17:36:26 +02:00
examples changed target name 2019-04-02 17:36:26 +02:00
include/argparse created subcommands 2019-05-27 23:31:58 +02:00
src created subcommands 2019-05-27 23:31:58 +02:00
test created subcommands 2019-05-27 23:31:58 +02:00
.core.yml created subcommands 2019-05-27 23:31:58 +02:00
.gitignore removed rubbish 2019-03-11 22:48:19 +01:00
.valgrind-suppressions fixed valgrind error 2019-03-12 14:56:00 +01:00
CMakeLists.txt created subcommands 2019-05-27 23:31:58 +02:00
Dockerfile added rpm to docker file 2019-03-22 10:55:32 +01:00
LICENSE.txt support duplicate options and added cmake config 2019-03-22 10:46:04 +01:00
README.md added basic readme 2019-03-12 13:35:25 +01:00

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