Now you can give an option the combination of flags
COMMAND_LINE_VALUE_OPTIONAL and COMMAND_LINE_VALUE_BOOL. If you do,
then all three of the syntaxes +foo, -foo and /foo:value are allowed
at once, and the receiving code can tell the difference because the
Value field is set to BoolValueTrue, BoolValueFalse or a valid char
pointer.
(cherry picked from commit
22c6b375d4ae9bf9dcac74d3360d0042673f1353)
if (text)
fprintf(fp, "%s", text);
- if (arg->Flags == COMMAND_LINE_VALUE_BOOL)
+ if (arg->Flags & COMMAND_LINE_VALUE_BOOL &&
+ (!arg->Default || arg->Default == BoolValueTrue))
fprintf(fp, " (default:%s)", arg->Default ? "on" : "off");
else if (arg->Default)
{
if (value)
{
- if (options[j].Flags & (COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_VALUE_BOOL))
+ if (!(options[j].Flags &
+ (COMMAND_LINE_VALUE_OPTIONAL | COMMAND_LINE_VALUE_REQUIRED)))
{
log_error(flags, "Failed at index %d [%s]: Unexpected value", i, argv[i]);
return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;