Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HelpCalled and HasErrors preserve values when Parse(args) is called multiple times #96

Open
agracio opened this issue Feb 15, 2018 · 5 comments

Comments

@agracio
Copy link

agracio commented Feb 15, 2018

In an app that uses fluent-command-line-parser continuously var result = Parse(args) sets result.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 have result.HasErrors set to false.
Using version 1.5.0.20

@agracio agracio changed the title HelpCalled stays 'true' if help called once HelpCalled and HasErrors preserve values when Parse(args) is called multiple times Feb 15, 2018
@siywilliams
Copy link
Member

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.

@agracio
Copy link
Author

agracio commented Feb 15, 2018

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 :)

@agracio
Copy link
Author

agracio commented Feb 16, 2018

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?

@siywilliams
Copy link
Member

I think the Help property will need to be reset also

@agracio
Copy link
Author

agracio commented Feb 16, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants