cofyc/argparse

Default value for arguments without parameter

Electronshik opened this issue · 0 comments

Hi! Could a flag be used with parameter and without parameter simultaneously?

For example smth like:
#define INT_DEFAULT_VALUE 10
OPT_BOOLEAN('f', "force", &force, "force to do", NULL, 0, 0),
OPT_INTEGER('i', "int", &int_num, "selected integer", NULL, 0, 0), //some way to transfer INT_DEFAULT_VALUE inside parser

my cmd -i 15 -f

force: 1
int_num: 15

Now it outputs next string:
my cmd -i -f

[int_num: 15](error: option -i expects an integer value)

But could the parameter be used with a default value like this:
my cmd -i -f

force: 1
int_num: 10