Skip to content

Default value for arguments without parameter #65

@Electronshik

Description

@Electronshik

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions