ADD: extended example to integer argument

This commit is contained in:
Dominik Meyer 2018-04-01 15:46:53 +02:00
parent 35bcf399b7
commit 1307609cff
No known key found for this signature in database
GPG Key ID: B4C312B600606B64

View File

@ -57,9 +57,25 @@ int main (int argc, char **argv)
/// add the argument command to context /// add the argument command to context
argparse_add_command(argparse_ctx, &test_cmd); 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 /// parse the commandline
int ret=argparse_parse(argparse_ctx, argc, argv); int ret=argparse_parse(argparse_ctx, argc, argv);
if (ret >= 0)
{
printf("Counter: %d\n", count);
}
/// free context /// free context
argparse_free(argparse_ctx); argparse_free(argparse_ctx);