TCmdLineParser.Execute stops at the first syntax error: a TEngineStateError raises EStateEngineError at once, and the options and parameters are only handed out at the very end, so an error anywhere in the command line loses all of them.
That is why TDefaultMain.HasConsoleSwitch cannot use the parser to find --console and copies its rules by hand instead (stop at a lone - and at the first parameter, skip the value of a short option). The copy differs from the parser for quoted arguments: for prog "-x" --console, ParamStr drops the quotes and HasConsoleSwitch finds the switch, while the parser takes "-x" as a parameter and accepts no options after it. Using the parser as it is would lose the switch for prog --console -ns, and the syntax error would then be shown in a dialog, which is exactly what --console is meant to prevent.
Proposed:
Execute raises the recorded error after the whole command line was read, with the same message as now, so TGetOpt behaves as before.TryExecute returns the options and parameters together with the error message instead of raising.TDefaultMain.ConsoleSwitchPassed uses TryExecute on the program's command line and looks for a console option without a value, so it agrees with TGetOpt by construction, quoting included.Found while working on [bugs:#78].
Fixed in revisions [r2491] and [r2492].
Related
Commit: [r2491]
Commit: [r2492]