Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default value for arguments without parameter #65

Open
Electronshik opened this issue Nov 15, 2023 · 0 comments
Open

Default value for arguments without parameter #65

Electronshik opened this issue Nov 15, 2023 · 0 comments

Comments

@Electronshik
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant