From 1307609cffcb8144dd37e5d7836b9a1ae7ea7b80 Mon Sep 17 00:00:00 2001 From: Dominik Meyer Date: Sun, 1 Apr 2018 15:46:53 +0200 Subject: [PATCH] ADD: extended example to integer argument --- examples/example1.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/examples/example1.c b/examples/example1.c index f9026bd..edea44b 100644 --- a/examples/example1.c +++ b/examples/example1.c @@ -57,9 +57,25 @@ int main (int argc, char **argv) /// add the argument command to context argparse_add_command(argparse_ctx, &test_cmd); + int count; + struct arg_int test_int = { + {ARG_INT,0,0}, + 'c', + "count", + "just a counting value", + &count + }; + /// add the argument int to context + argparse_add_int(argparse_ctx, &test_int); + /// parse the commandline int ret=argparse_parse(argparse_ctx, argc, argv); + if (ret >= 0) + { + printf("Counter: %d\n", count); + } + /// free context argparse_free(argparse_ctx);