winpr/utils: allow COMMAND_LINE_VALUE_{OPTIONAL,BOOL} to coexist.
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.
This commit is contained in:
parent
3c104d9b9b
commit
c90479c7f5
@ -244,7 +244,8 @@ int main(int argc, char* argv[])
|
||||
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)
|
||||
{
|
||||
|
@ -312,7 +312,8 @@ int CommandLineParseArgumentsA(int argc, LPSTR* argv, COMMAND_LINE_ARGUMENT_A* o
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user