-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Refactor arg validation #2862
Refactor arg validation #2862
Conversation
I was thinking to tag each arg with ArgTypeCategory so it's more clear and whenever we add new arg, we are more likely to think about it. |
I saw the comments about exclusive sets and using the categories in the context cloning, but I missed the part where it said it wasn't needed in this PR :D I added a new type for the couple of fields in an argument that I'm using here: the name (for error messages), the categories and a new bitmask for exclusive sets. Since I added the name, I also put the alternate name and alias in here. |
Wow, that's way more than I would have ever expected! A cursory glance looks amazing, but I'll look closer once I've got some time |
Co-authored-by: yao-msft <[email protected]>
This change adds a set of argument "categories" that tell us what an argument is used for and makes it easier to reason around which arguments can be used at the same time. For example, a manifest arg cannot be used at the same time as an arg related to sources.
The main change is adding a function to identify the categories of arguments used in an invocation, and a function to use those categories for validation. Then, I used these new functions to replace the arg validation for commands that had similar rules.
This is what I wanted to do for #1788, and should make arg validation for #2861 easier to get right.
Microsoft Reviewers: Open in CodeFlow