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

Allow multiple apps in a single command #2861

Merged
merged 30 commits into from
Feb 6, 2023

Conversation

florelis
Copy link
Member

@florelis florelis commented Jan 17, 2023

This change adds support specifying multiple packages in a single command for install, update and uninstall. For example, winget install app1 app2.

  • Added a new argument type called MultiQuery, which is the same as Query but has a limit for values larger than 1. Thankfully the arg parsing was already implemented :)
  • Used this new argument in the install, upgrade and uninstall commands. The first step in these commands is now to check if MultiQuery has more than 1 value, and if it doesn't it is replaced by a single Query argument. This way, the change is not visible to existing code.
  • If there is more than one value for the multi-query argument, we proceed to search for each query in a separate sub-query, and then we install them all one at a time. The code for this is refactored from the import flow which does pretty much the same thing.
  • Added unit tests for these 3 commands.

I did not extend argument validation in this PR. Ideally we would block arguments that don't make sense for more than one package when doing multi-queries, like --override. I will send a separate PR to refactor the argument validation to make this easier without repeating it in the three commands.

Closes #219

Microsoft Reviewers: Open in CodeFlow

@florelis florelis requested a review from a team as a code owner January 17, 2023 20:59
@ghost ghost added the Issue-Feature This is a feature request for the Windows Package Manager client. label Jan 17, 2023
src/AppInstallerCLICore/Commands/InstallCommand.cpp Outdated Show resolved Hide resolved
if (!foundAll)
{
AICLI_LOG(CLI, Info, << "Could not find one or more packages");
if (context.Args.Contains(Execution::Args::Type::IgnoreUnavailable))
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this arg need to be added to install / upgrade in case one of the multiqueries returns no packages? What happens if the user runs winget install 7zip chrome ThisExampleIsNotPresent? Would all packages fail, or would 7zip and chrome still be installed?

Copy link
Member Author

Choose a reason for hiding this comment

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

It does not need to be added, but we could add it. As it is, it would fail with a message that not all packages were found before installing anything.

Copy link

Choose a reason for hiding this comment

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

Failing is desirable so as to avoid confusion about what installed vs failed!

src/AppInstallerCLICore/ExecutionArgs.h Outdated Show resolved Hide resolved
src/AppInstallerCLICore/Workflows/WorkflowBase.cpp Outdated Show resolved Hide resolved
src/AppInstallerCLICore/Workflows/MultiQueryFlow.cpp Outdated Show resolved Hide resolved
src/AppInstallerCLICore/Workflows/MultiQueryFlow.cpp Outdated Show resolved Hide resolved
src/AppInstallerCLICore/Workflows/MultiQueryFlow.cpp Outdated Show resolved Hide resolved
src/AppInstallerCLICore/Workflows/MultiQueryFlow.cpp Outdated Show resolved Hide resolved
@florelis
Copy link
Member Author

Only thing pending now should be arg validation, which once I merge #2862 will be only tagging the arg with the right categories. Although it will have to be a special case since it depends on whether it has one or multiple values.

src/AppInstallerCLICore/Commands/InstallCommand.cpp Outdated Show resolved Hide resolved
{
context <<
Workflow::GetMultiSearchRequests <<
Workflow::SearchSubContextsForSingle(Workflow::SearchSubContextsForSingle::SearchPurpose::Uninstall) <<
Copy link
Contributor

Choose a reason for hiding this comment

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

After reading through this again, it seems like the implementation in #2877 of SearchResultType and the SearchPurpose here are similar; Would it make sense to align them both to SearchPurpose and use it more globally rather than inside the namespace of SearchSubContextsForSingle?

If so, I'll update that PR

src/AppInstallerCLICore/Workflows/WorkflowBase.cpp Outdated Show resolved Hide resolved
src/AppInstallerCLITests/Command.cpp Outdated Show resolved Hide resolved
src/AppInstallerCLITests/Command.cpp Show resolved Hide resolved
src/AppInstallerCLITests/Command.cpp Show resolved Hide resolved
src/AppInstallerCLITests/Command.cpp Show resolved Hide resolved
Copy link
Contributor

@yao-msft yao-msft left a comment

Choose a reason for hiding this comment

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

:shipit:

florelis and others added 6 commits January 31, 2023 14:59
# Conflicts:
#	src/AppInstallerCLICore/Argument.cpp
#	src/AppInstallerCLICore/Commands/InstallCommand.cpp
#	src/AppInstallerCLICore/Commands/UninstallCommand.cpp
#	src/AppInstallerCLICore/Commands/UpgradeCommand.cpp
#	src/AppInstallerCLICore/ExecutionArgs.h
#	src/AppInstallerCLICore/Resources.h
#	src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw
@florelis florelis merged commit fcce38f into microsoft:master Feb 6, 2023
@florelis florelis deleted the multiinstall branch February 6, 2023 21:52
@emoxam
Copy link

emoxam commented Feb 7, 2023

When and how ill we get the new release ?

@yao-msft
Copy link
Contributor

yao-msft commented Feb 7, 2023

If you are looking for stable releases, this will be included in v1.5 client release tracked by milestone here https://github.com/microsoft/winget-cli/milestone/39
It is planned to be released around May

If you are looking to test it early, you can join the Windows Insider program to get preview builds, or watch our release page here https://github.com/microsoft/winget-cli/releases

@emoxam
Copy link

emoxam commented Feb 8, 2023

Where can i get Windows Insider program to get preview builds ?

@denelon
Copy link
Contributor

denelon commented Feb 8, 2023

https://insider.windows.com/ 😊

@emoxam
Copy link

emoxam commented Feb 9, 2023

I mean - on github there are words Development Releases - "Join the Windows Package Manager Insider program by signing up."
and
"If you decide to install the latest release from GitHub, and you have successfully joined the insider program, you will receive updates when the next development release has been published in the Microsoft Store."
I've joined, and i've got mail a few days ago, but MS store has nothing to give me, i have winget -v
v1.4.10173
and no update so far. What is going on ? Where is a new version? For example this one https://github.com/microsoft/winget-cli/releases/tag/v1.5.101-preview

@Trenly
Copy link
Contributor

Trenly commented Feb 9, 2023

I mean - on github there are words Development Releases - "Join the Windows Package Manager Insider program by signing up." and "If you decide to install the latest release from GitHub, and you have successfully joined the insider program, you will receive updates when the next development release has been published in the Microsoft Store." I've joined, and i've got mail a few days ago, but MS store has nothing to give me, i have winget -v v1.4.10173 and no update so far. What is going on ? Where is a new version? For example this one v1.5.101-preview (release)

Preview releases aren't cut after every PR. There is internal validation and testing that has to happen before a release is cut. I would think it would be another week or two before these changes are available in a preview

@emoxam
Copy link

emoxam commented Feb 9, 2023

What we gave at store is 1.19.10173 - how does this relate to github versions ? There is no 1.19 at github!

@Trenly
Copy link
Contributor

Trenly commented Feb 9, 2023

What we gave at store is 1.19.10173 - how does this relate to github versions ? There is no 1.19 at github!

AppInstaller contains winget, but it is not winget itself; The version marked Latest in Github Releases is what is bundled with the AppInstaller from MSStore (unless you're on an insider build)

1 similar comment
@Trenly
Copy link
Contributor

Trenly commented Feb 9, 2023

What we gave at store is 1.19.10173 - how does this relate to github versions ? There is no 1.19 at github!

AppInstaller contains winget, but it is not winget itself; The version marked Latest in Github Releases is what is bundled with the AppInstaller from MSStore (unless you're on an insider build)

@emoxam
Copy link

emoxam commented Feb 9, 2023

So no hope to wait new appinstaller at store ?

@florelis
Copy link
Member Author

florelis commented Feb 9, 2023

What we gave at store is 1.19.10173 - how does this relate to github versions ? There is no 1.19 at github!

I know it doesn't seem to make sense, but there is a difference of 15 between the minor version of the App Installer package and the minor version of the winget cli. App Installer v1.19.10173 includes winget v1.4.10173.

This change will come in the preview for winget v1.5, so it will be a App Installer v1.20.

I think it takes some time to start getting preview builds after joining the insider program. Once you see you're on a v1.5 build you'll know you are receiving preview builds, so you should get the one with this change once it's out.

@emoxam
Copy link

emoxam commented Feb 10, 2023

So i should look at store to see if there an update to App Installer v1.20 ?
P.S. Maybe it could be useful to write somewhere at package description what version of wiget it includes ?

@Trenly Trenly mentioned this pull request Jul 24, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Feature This is a feature request for the Windows Package Manager client.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow multiple apps to be installed using a single command
6 participants