What is `OPT_NONEG` doing?
Closed this issue · 3 comments
CMCDragonkai commented
And what are the flags for argparse_init
? The example only shows 0
.
cofyc commented
hi,
OPT_BOOLEAN
and OPT_BIT
types support negation, you can use no-
prefix to negate the value, for example:
OPT_BIT(0, "read", &perms, "read perm", NULL, PERM_READ, OPT_NONEG),
OPT_BIT(0, "write", &perms, "write perm", NULL, PERM_WRITE),
OPT_BIT(0, "exec", &perms, "exec perm", NULL, PERM_EXEC),
--write
turns on write permission, --no-exec
means no exec permission.
But, if you don't want this feature, you can use OPT_NONEG
flag to turn off this feature. In the example above, --no-write
and --no-exec
is valid, but --no-read
is invalid.
CMCDragonkai commented
Can those flags be put into argparse_init(&argparse, options, usage, 0);
. See the 0
at the end?
Also the 0
for OPT_BIT
, does that mean there's no short option for read? So it's equivalent to NULL
?
cofyc commented
NO, OPT_NONEG
is per OPT
flag.