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

[ts-command-line] Prevent ambiguous abbreviations of parameters defined on parent tool or action #4405

Merged

Conversation

D4N14L
Copy link
Member

@D4N14L D4N14L commented Oct 23, 2023

Summary

Consider parameters defined on the parent tool and (if applicable) parent action when preventing ambiguous parameter usage or ambiguous parameter abbreviations.

Details

Previously, it was possible to define a parameter on a parent tool or action, and not have an error thrown when the child action declares either an identical parameter or a parameter that has an ambiguous abbreviation when considering the parent parameters.

Ex. Given a tool heft with a defined parameter --debug and a defined action test with a defined parameter --debug:

  • heft --debug test and heft test --debug are valid invocations of the heft tool, but the parameters would be handled differently
  • Similarly, heft --debug test --debug would also be considered a valid command

This also applies to the automatic abbreviations that are supported by ts-command-line.

Ex. Given a tool heft with a defined parameter --debug and a defined action test with a defined parameter --debug-mode:

  • heft --debug test and heft test --debug are valid invocations of the heft tool, but the parameters would be handled differently
  • Similarly, heft --debug test --debug would also be considered a valid command

With this change, parent parameters are considered when looking for ambiguous parameter references.

Ex. Given a tool heft with a defined parameter --debug and a defined action test:

  • Defining a parameter --debug on the test action will throw an error regarding duplicate parameters
  • Defining a parameter --debug-mode on the test action is valid
    • heft --debug test is still valid
    • heft test --debug will throw an error regarding ambiguous parameter usage
    • heft test --debug- is valid, as it is an unambiguous abbreviation of the --debug-mode parameter
       

How it was tested

Added a bunch of unit tests.

Impacted documentation

May require updating website docs on ts-command-line

@D4N14L D4N14L requested a review from patmill as a code owner October 24, 2023 16:50
common/reviews/api/ts-command-line.api.md Outdated Show resolved Hide resolved
@D4N14L D4N14L enabled auto-merge October 30, 2023 21:23
@D4N14L D4N14L merged commit af265e5 into microsoft:main Oct 30, 2023
5 checks passed
@iclanton iclanton deleted the user/danade/PreventAmbiguousAbbreviations branch October 30, 2023 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants