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

Make UnrecognizedArgumentHandling per command scope #371

Merged
merged 7 commits into from
Aug 28, 2020
Merged

Make UnrecognizedArgumentHandling per command scope #371

merged 7 commits into from
Aug 28, 2020

Conversation

scott-xu
Copy link
Contributor

@scott-xu scott-xu commented Jun 13, 2020

Fix #370

@scott-xu scott-xu requested a review from natemcmaster as a code owner June 13, 2020 08:13
@scott-xu
Copy link
Contributor Author

This PR is to reproduce #370.
I also have a fix for it which is to inherit the setting from parent if not set. But I need to know if it is the right direction to go. @natemcmaster

@natemcmaster natemcmaster changed the base branch from master to main June 14, 2020 22:17
@scott-xu scott-xu changed the title WIP reproduce https://github.com/natemcmaster/CommandLineUtils/issues/370 Make UnrecognizedArgumentHandling per command scope Jun 23, 2020
Currently the setting `OptionNameValueSeparators` in sub command does not take effect, which is the same with `UnrecognizedArgumentHandling`. This commit fixed the issue.
@natemcmaster
Copy link
Owner

/azp run all

@azure-pipelines
Copy link
Contributor

No pipelines are associated with this pull request.

@natemcmaster
Copy link
Owner

/azp run

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 1 pipeline(s).

@@ -31,12 +30,10 @@ private CommandLineApplication _currentCommand

public CommandLineProcessor(
CommandLineApplication command,
ParserConfig config,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change, is there any point to keeping the ParserConfig class?

It seems this is sort of going the opposite direction I was hoping to go in #298. I was hoping to extract the parsing behavior of CommandLineApplication into a separate class completely.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to make the parser config per command, we have to associate them. If we want to inherit the config from parent command, we can’t do it inside ParserConfig as it has no info of its parent.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make the parser config per command

That's probably a bigger refactor than we need right now.

With this PR as is right now, does the ParserConfig class do anything? Or can it be deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ParserConfig is still needed. It is a property of CommandLineApplication. It tells the CommandLineApplication that each config is set or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure we can move the two properties of ParserConfig to CommandLineApplication as private fields and then delete ParserConfig.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that you want to avoid "big class". However, the UnrecognizedArgumentHandling and OptionNameValueSeparators are already published API about CommandLineApplication. It will be a breaking change if we remove it from CommandLineApplication.
As I said in #370 (comment), this PR has no open API change.

Copy link
Owner

@natemcmaster natemcmaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR and for your patience while I took a break from GitHub.

@natemcmaster natemcmaster merged commit 17476ab into natemcmaster:main Aug 28, 2020
@scott-xu scott-xu deleted the UnrecognizedArgumentHandling_SubCommand branch August 28, 2020 12:35
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

Successfully merging this pull request may close these issues.

UnrecognizedArgumentHandling options are cheking in all commands
2 participants