-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Bring Pinning to PowerShell Cmdlets #6190
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
base: master
Are you sure you want to change the base?
Changes from 8 commits
32b17d4
697ca1d
b6502ef
ae483b0
fac4ec4
7ce3b27
35322e7
236e667
1c89957
fa617a6
7f33f56
3c7d4a6
99a8760
e336194
0cb653b
29d6203
184cc7a
952e56e
e823b75
195846f
0468b34
4bfde99
243798b
4b7b8ef
e93e3d1
ae87ff1
917db77
34a727c
01aad8e
ad9932f
a96e43e
fde7382
d5f682c
8f819c1
91f532a
595abca
7e83a83
615ddca
1f8932d
df55096
6d085dd
ea9f0d8
d207c77
349a0a1
840e5ae
65f8373
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,7 +3,9 @@ | |||||||||||||||
| #include "pch.h" | ||||||||||||||||
| #include "Resources.h" | ||||||||||||||||
| #include "PinFlow.h" | ||||||||||||||||
| #include "ShowFlow.h" | ||||||||||||||||
| #include "TableOutput.h" | ||||||||||||||||
| #include <AppInstallerDateTime.h> | ||||||||||||||||
| #include <winget/PinningData.h> | ||||||||||||||||
| #include <winget/RepositorySearch.h> | ||||||||||||||||
| #include <winget/PackageVersionSelection.h> | ||||||||||||||||
|
|
@@ -197,9 +199,21 @@ namespace AppInstaller::CLI::Workflow | |||||||||||||||
|
|
||||||||||||||||
| if (!pinsToAddOrUpdate.empty()) | ||||||||||||||||
| { | ||||||||||||||||
| for (const auto& pin : pinsToAddOrUpdate) | ||||||||||||||||
| std::string dateAdded = Utility::TimePointToString( | ||||||||||||||||
|
Trenly marked this conversation as resolved.
Outdated
|
||||||||||||||||
| std::chrono::system_clock::now(), | ||||||||||||||||
| Utility::TimeFacet::Year | Utility::TimeFacet::Month | Utility::TimeFacet::Day | | ||||||||||||||||
| Utility::TimeFacet::Hour | Utility::TimeFacet::Minute | Utility::TimeFacet::Second); | ||||||||||||||||
|
|
||||||||||||||||
| std::optional<std::string> note; | ||||||||||||||||
| if (context.Args.Contains(Execution::Args::Type::PinNote)) | ||||||||||||||||
| { | ||||||||||||||||
| note = std::string{ context.Args.GetArg(Execution::Args::Type::PinNote) }; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| for (auto& pin : pinsToAddOrUpdate) | ||||||||||||||||
| { | ||||||||||||||||
| pin.SetDateAdded(dateAdded); | ||||||||||||||||
|
Trenly marked this conversation as resolved.
Outdated
|
||||||||||||||||
| pin.SetNote(note); | ||||||||||||||||
| pinningData.AddOrUpdatePin(pin); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -335,4 +349,103 @@ namespace AppInstaller::CLI::Workflow | |||||||||||||||
| context.Reporter.Info() << Resource::String::PinNoPinsExist << std::endl; | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| void ShowPinDetails(Execution::Context& context) | ||||||||||||||||
| { | ||||||||||||||||
| auto& pinningData = context.Get<Execution::Data::PinningData>(); | ||||||||||||||||
| auto allPins = pinningData.GetAllPins(); | ||||||||||||||||
|
|
||||||||||||||||
| // Apply filtering based on provided arguments | ||||||||||||||||
| bool hasId = context.Args.Contains(Execution::Args::Type::Id); | ||||||||||||||||
| bool hasName = context.Args.Contains(Execution::Args::Type::Name); | ||||||||||||||||
| bool hasQuery = context.Args.Contains(Execution::Args::Type::Query); | ||||||||||||||||
| bool exactMatch = context.Args.Contains(Execution::Args::Type::Exact); | ||||||||||||||||
|
|
||||||||||||||||
|
||||||||||||||||
| if (!hasId && !hasName && !hasQuery) | |
| { | |
| context.Reporter.Error() << "The 'pin show' command requires at least one of --id, --name, or --query." << std::endl; | |
| AICLI_TERMINATE_CONTEXT(APPINSTALLER_CLI_ERROR_INVALID_CL_ARGUMENTS); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer that we follow the model of package list and have
--detailson the existinglistcommand. That also removes the need to create a whole new search mechanism and just makes the change inReportPins.Followup: Well it looks like it would need a whole new search mechanism to actually implement the arguments that it claims to support...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we would need a whole new search mechanism anyways. I do think that there is some overlap with
winget list <query> --details, but to me it felt more akin towinget show <query>. The semantics oflistvsshowas a base command don't really apply to pins. Whereshowin the base command is for a remote package / manifest information,listis for installed applications.I will think on this and probably end up refactoring to extend the behavior of list instead of adding show