Skip to content

Implement better validation of how CLI arguments are used together #1788

Closed

Description

Description of the new feature / enhancement

The current validation of arguments seems to miss many combinations of arguments that don't make sense together. For example, the upgrade commands allows winget upgrade --all -v 1.0 (version is used only when upgrading single package, not all of them) or winget upgrade -m myManifest.yaml --accept-source-agreements (sources are not used with local manifest, so there are no agreements).

We should improve that validation, preferably in a way that makes it easier to extend as we add more arguments.

Proposed technical implementation details

I think we could create "categories" of arguments and define the rules on top of them. For example, for upgrade there are arguments for selecting the package (e.g. id, version), arguments for selecting multiple packages (--all, --include-unknown), and arguments for the sources (source name, REST source header, agreements). We could define rules on top of them like disallowing arguments for both single and multiple packages, or for sources when including a local manifest. Adding a new argument to one category would include it in all existing rules easily.

Activity

  1. added
    Issue-Feature
    on Dec 10, 2021
  2. ghost added
    Needs-Triage
    on Dec 10, 2021
  3. JohnMcPMS commented on Jan 19, 2022

    @JohnMcPMS
    Member

    Indeed, Powershell's parameter sets was something I had considered when this was originally written. At the time it wasn't really worth it, but I assumed we could just add it later. I still think we could do so easily.

    I would argue for keeping them separate as in sets, rather than tagging each argument with flags. That way, each set can have custom documentation (if needed) for the argument.

  4. Trenly commented on May 3, 2023

    @Trenly
    Contributor

    Flor Chacón (@florelis) - Is this resolved with the above PR?

  5. florelis commented on May 3, 2023

    @florelis
    MemberAuthor

    Flor Chacón (@florelis) Is this resolved with the above PR?

    I think the PR does what I wanted so I'll close this. Maybe in the future we'll want to do what JohnMcPMS suggested about sets, but that can be a different issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Feature

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions