-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Client credentials now work #74 * Crazy fast winget package search
- Loading branch information
Showing
14 changed files
with
785 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/Svrooij.WinTuner.CmdLets/Commands/SearchWtWinGetPackage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Svrooij.PowerShell.DependencyInjection; | ||
using System; | ||
using System.Management.Automation; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Svrooij.WinTuner.CmdLets.Commands; | ||
|
||
/// <summary> | ||
/// <para type="synopsis">Search for packages in winget</para> | ||
/// <para type="description">Search for WinGet packages, but faster</para> | ||
/// </summary> | ||
/// <example> | ||
/// <para type="description">Search for 'fire', did I tell you it's fast?</para> | ||
/// <code>Search-WtWinGetPackage fire</code> | ||
/// </example> | ||
[Cmdlet(VerbsCommon.Search, "WtWinGetPackage", HelpUri = "https://wintuner.app/docs/wintuner-powershell/Search-WtWingetPackage")] | ||
[OutputType(typeof(Winget.CommunityRepository.Models.WingetEntry[]))] | ||
public class SearchWtWinGetPackage : DependencyCmdlet<Startup> | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
[Parameter( | ||
Mandatory = true, | ||
Position = 0, | ||
ValueFromPipeline = true, | ||
ValueFromPipelineByPropertyName = true, | ||
HelpMessage = "Part of the package ID, 2 characters minimum")] | ||
public string? PackageId { get; set; } | ||
|
||
[ServiceDependency] | ||
private Winget.CommunityRepository.WingetRepository wingetRepository; | ||
|
||
/// <inheritdoc /> | ||
public override async Task ProcessRecordAsync(CancellationToken cancellationToken) | ||
{ | ||
if (string.IsNullOrWhiteSpace(PackageId) || PackageId.Length <= 1) | ||
{ | ||
throw new ArgumentException("PackageId is required"); | ||
} | ||
var packages = await wingetRepository.SearchPackage(PackageId ?? throw new ArgumentNullException(nameof(PackageId)), cancellationToken); | ||
|
||
WriteObject(packages); | ||
} | ||
} |
Oops, something went wrong.