Open agracio opened 6 years ago
Hi @agracio ,
Yes the internals of fclp remember some state from the last parse operation. It would be safer to recreate the fclp for each subsequent call at this stage until it can be changed to be state-less.
I have considered this approach as a workaround, but my app has complex setup stage and recreating it can add overhead to command parsing times, is there a way reset state? I am already forced to use reflection for some features so adding one more internal call cannot hurt :)
I think I solved the problem by re-initialising ParseEngine property before each call.
parser.ParseEngine = new CommandLineParserEngineMark2(new SpecialCharacters());
Is that enough to reset internal state?
I think the Help property will need to be reset also
So far my tests show that both HelpCalled and HasErrors are reset between multiple invocations of Parse(args)
method. I will update this thread if I encounter other issues.
In an app that uses fluent-command-line-parser continuously
var result = Parse(args)
setsresult.HelpCalled
to true when help is called and stays true for all sub-sequential command calls.Edit:
result.HasErrors
behaves similarly by setting value to false when one successful command is called. All incorrect commands after that will still haveresult.HasErrors
set to false. Using version 1.5.0.20