@@ -52,9 +52,10 @@ public WinGetPackageManager()
5252 /// <summary>
5353 /// Uses the winget search function to search for a package that maches the given name.
5454 /// </summary>
55- /// <param name="packageName ">
56- /// The name of the package for the search.
55+ /// <param name="packageId ">
56+ /// The id or name of the package for the search.
5757 /// </param>
58+ /// <param name="exact">Use exact match.</param>
5859 /// <returns>
5960 /// A <see cref="System.Collections.Generic.List{T}"/> of <see cref="WGetNET.WinGetPackage"/> instances.
6061 /// </returns>
@@ -65,13 +66,19 @@ public WinGetPackageManager()
6566 /// The current action failed for an unexpected reason.
6667 /// Please see inner exception.
6768 /// </exception>
68- public List < WinGetPackage > SearchPackage ( string packageName )
69+ public List < WinGetPackage > SearchPackage ( string packageId , bool exact = false )
6970 {
7071 try
7172 {
73+ string cmd = string . Format ( _searchCmd , packageId ) ;
74+
75+ if ( exact )
76+ {
77+ cmd += " --exact" ;
78+ }
79+
7280 ProcessResult result =
73- _processManager . ExecuteWingetProcess (
74- string . Format ( _searchCmd , packageName ) ) ;
81+ _processManager . ExecuteWingetProcess ( cmd ) ;
7582
7683 return ProcessOutputReader . ToPackageList ( result . Output , PackageAction . Search ) ;
7784 }
@@ -88,12 +95,13 @@ public List<WinGetPackage> SearchPackage(string packageName)
8895 /// <summary>
8996 /// Uses the winget search function to search for a package that maches the given name.
9097 /// </summary>
91- /// <param name="packageName ">
92- /// The name of the package for the search.
98+ /// <param name="packageId ">
99+ /// The id or name of the package for the search.
93100 /// </param>
94101 /// <param name="sourceName">
95102 /// The name of the source for the search.
96103 /// </param>
104+ /// <param name="exact">Use exact match.</param>
97105 /// <returns>
98106 /// A <see cref="System.Collections.Generic.List{T}"/> of <see cref="WGetNET.WinGetPackage"/> instances.
99107 /// </returns>
@@ -104,13 +112,19 @@ public List<WinGetPackage> SearchPackage(string packageName)
104112 /// The current action failed for an unexpected reason.
105113 /// Please see inner exception.
106114 /// </exception>
107- public List < WinGetPackage > SearchPackage ( string packageName , string sourceName )
115+ public List < WinGetPackage > SearchPackage ( string packageId , string sourceName , bool exact = false )
108116 {
109117 try
110118 {
119+ string cmd = string . Format ( _searchBySourceCmd , packageId , sourceName ) ;
120+
121+ if ( exact )
122+ {
123+ cmd += " --exact" ;
124+ }
125+
111126 ProcessResult result =
112- _processManager . ExecuteWingetProcess (
113- string . Format ( _searchBySourceCmd , packageName , sourceName ) ) ;
127+ _processManager . ExecuteWingetProcess ( cmd ) ;
114128
115129 return ProcessOutputReader . ToPackageList ( result . Output , PackageAction . SearchBySource , sourceName ) ;
116130 }
@@ -127,9 +141,10 @@ public List<WinGetPackage> SearchPackage(string packageName, string sourceName)
127141 /// <summary>
128142 /// Uses the winget search function to asynchronously search for a package that maches the given name.
129143 /// </summary>
130- /// <param name="packageName ">
131- /// The name of the package for the search.
144+ /// <param name="packageId ">
145+ /// The id or name of the package for the search.
132146 /// </param>
147+ /// <param name="exact">Use exact match.</param>
133148 /// <returns>
134149 /// A <see cref="System.Threading.Tasks.Task"/>, containing the result.
135150 /// The result is a <see cref="System.Collections.Generic.List{T}"/> of <see cref="WGetNET.WinGetPackage"/> instances.
@@ -141,13 +156,19 @@ public List<WinGetPackage> SearchPackage(string packageName, string sourceName)
141156 /// The current action failed for an unexpected reason.
142157 /// Please see inner exception.
143158 /// </exception>
144- public async Task < List < WinGetPackage > > SearchPackageAsync ( string packageName )
159+ public async Task < List < WinGetPackage > > SearchPackageAsync ( string packageId , bool exact = false )
145160 {
146161 try
147162 {
163+ string cmd = string . Format ( _searchCmd , packageId ) ;
164+
165+ if ( exact )
166+ {
167+ cmd += " --exact" ;
168+ }
169+
148170 ProcessResult result =
149- await _processManager . ExecuteWingetProcessAsync (
150- string . Format ( _searchCmd , packageName ) ) ;
171+ await _processManager . ExecuteWingetProcessAsync ( cmd ) ;
151172
152173 return ProcessOutputReader . ToPackageList ( result . Output , PackageAction . Search ) ;
153174 }
@@ -164,12 +185,13 @@ await _processManager.ExecuteWingetProcessAsync(
164185 /// <summary>
165186 /// Uses the winget search function to asynchronously search for a package that maches the given name.
166187 /// </summary>
167- /// <param name="packageName ">
168- /// The name of the package for the search.
188+ /// <param name="packageId ">
189+ /// The id or name of the package for the search.
169190 /// </param>
170191 /// <param name="sourceName">
171192 /// The name of the source for the search.
172193 /// </param>
194+ /// <param name="exact">Use exact match.</param>
173195 /// <returns>
174196 /// A <see cref="System.Threading.Tasks.Task"/>, containing the result.
175197 /// The result is a <see cref="System.Collections.Generic.List{T}"/> of <see cref="WGetNET.WinGetPackage"/> instances.
@@ -181,13 +203,19 @@ await _processManager.ExecuteWingetProcessAsync(
181203 /// The current action failed for an unexpected reason.
182204 /// Please see inner exception.
183205 /// </exception>
184- public async Task < List < WinGetPackage > > SearchPackageAsync ( string packageName , string sourceName )
206+ public async Task < List < WinGetPackage > > SearchPackageAsync ( string packageId , string sourceName , bool exact = false )
185207 {
186208 try
187209 {
210+ string cmd = string . Format ( _searchBySourceCmd , packageId , sourceName ) ;
211+
212+ if ( exact )
213+ {
214+ cmd += " --exact" ;
215+ }
216+
188217 ProcessResult result =
189- await _processManager . ExecuteWingetProcessAsync (
190- string . Format ( _searchBySourceCmd , packageName , sourceName ) ) ;
218+ await _processManager . ExecuteWingetProcessAsync ( cmd ) ;
191219
192220 return ProcessOutputReader . ToPackageList ( result . Output , PackageAction . SearchBySource , sourceName ) ;
193221 }
@@ -238,9 +266,10 @@ public List<WinGetPackage> GetInstalledPackages()
238266 /// <summary>
239267 /// Gets a list of all installed packages. That match the provided name.
240268 /// </summary>
241- /// <param name="packageName ">
242- /// The name of the package for the search.
269+ /// <param name="packageId ">
270+ /// The id or name of the package for the search.
243271 /// </param>
272+ /// <param name="exact">Use exact match.</param>
244273 /// <returns>
245274 /// A <see cref="System.Collections.Generic.List{T}"/> of <see cref="WGetNET.WinGetPackage"/> instances.
246275 /// </returns>
@@ -251,12 +280,19 @@ public List<WinGetPackage> GetInstalledPackages()
251280 /// The current action failed for an unexpected reason.
252281 /// Please see inner exception.
253282 /// </exception>
254- public List < WinGetPackage > GetInstalledPackages ( string packageName )
283+ public List < WinGetPackage > GetInstalledPackages ( string packageId , bool exact = false )
255284 {
256285 try
257286 {
287+ string cmd = string . Format ( _searchInstalledCmd , packageId ) ;
288+
289+ if ( exact )
290+ {
291+ cmd += " --exact" ;
292+ }
293+
258294 ProcessResult result =
259- _processManager . ExecuteWingetProcess ( string . Format ( _searchInstalledCmd , packageName ) ) ;
295+ _processManager . ExecuteWingetProcess ( cmd ) ;
260296
261297 return ProcessOutputReader . ToPackageList ( result . Output , PackageAction . InstalledList ) ;
262298 }
@@ -273,12 +309,13 @@ public List<WinGetPackage> GetInstalledPackages(string packageName)
273309 /// <summary>
274310 /// Gets a list of all installed packages. That match the provided name.
275311 /// </summary>
276- /// <param name="packageName ">
277- /// The name of the package for the search.
312+ /// <param name="packageId ">
313+ /// The id or name of the package for the search.
278314 /// </param>
279315 /// <param name="sourceName">
280316 /// The name of the source for the search.
281317 /// </param>
318+ /// <param name="exact">Use exact match.</param>
282319 /// <returns>
283320 /// A <see cref="System.Collections.Generic.List{T}"/> of <see cref="WGetNET.WinGetPackage"/> instances.
284321 /// </returns>
@@ -289,12 +326,19 @@ public List<WinGetPackage> GetInstalledPackages(string packageName)
289326 /// The current action failed for an unexpected reason.
290327 /// Please see inner exception.
291328 /// </exception>
292- public List < WinGetPackage > GetInstalledPackages ( string packageName , string sourceName )
329+ public List < WinGetPackage > GetInstalledPackages ( string packageId , string sourceName , bool exact = false )
293330 {
294331 try
295332 {
333+ string cmd = string . Format ( _searchInstalledBySourceCmd , packageId , sourceName ) ;
334+
335+ if ( exact )
336+ {
337+ cmd += " --exact" ;
338+ }
339+
296340 ProcessResult result =
297- _processManager . ExecuteWingetProcess ( string . Format ( _searchInstalledBySourceCmd , packageName , sourceName ) ) ;
341+ _processManager . ExecuteWingetProcess ( cmd ) ;
298342
299343 return ProcessOutputReader . ToPackageList ( result . Output , PackageAction . InstalledListBySource , sourceName ) ;
300344 }
@@ -344,9 +388,10 @@ public async Task<List<WinGetPackage>> GetInstalledPackagesAsync()
344388 /// <summary>
345389 /// Asynchronously gets a list of all installed packages. That match the provided name.
346390 /// </summary>
347- /// <param name="packageName ">
348- /// The name of the package for the search.
391+ /// <param name="packageId ">
392+ /// The id or name of the package for the search.
349393 /// </param>
394+ /// <param name="exact">Use exact match.</param>
350395 /// <returns>
351396 /// A <see cref="System.Threading.Tasks.Task"/>, containing the result.
352397 /// The result is a <see cref="System.Collections.Generic.List{T}"/> of <see cref="WGetNET.WinGetPackage"/> instances.
@@ -358,12 +403,19 @@ public async Task<List<WinGetPackage>> GetInstalledPackagesAsync()
358403 /// The current action failed for an unexpected reason.
359404 /// Please see inner exception.
360405 /// </exception>
361- public async Task < List < WinGetPackage > > GetInstalledPackagesAsync ( string packageName )
406+ public async Task < List < WinGetPackage > > GetInstalledPackagesAsync ( string packageId , bool exact = false )
362407 {
363408 try
364409 {
410+ string cmd = string . Format ( _searchInstalledCmd , packageId ) ;
411+
412+ if ( exact )
413+ {
414+ cmd += " --exact" ;
415+ }
416+
365417 ProcessResult result =
366- await _processManager . ExecuteWingetProcessAsync ( string . Format ( _searchInstalledCmd , packageName ) ) ;
418+ await _processManager . ExecuteWingetProcessAsync ( cmd ) ;
367419
368420 return ProcessOutputReader . ToPackageList ( result . Output , PackageAction . InstalledList ) ;
369421 }
@@ -380,12 +432,13 @@ public async Task<List<WinGetPackage>> GetInstalledPackagesAsync(string packageN
380432 /// <summary>
381433 /// Asynchronously gets a list of all installed packages. That match the provided name.
382434 /// </summary>
383- /// <param name="packageName ">
384- /// The name of the package for the search.
435+ /// <param name="packageId ">
436+ /// The id or name of the package for the search.
385437 /// </param>
386438 /// <param name="sourceName">
387439 /// The name of the source for the search.
388440 /// </param>
441+ /// <param name="exact">Use exact match.</param>
389442 /// <returns>
390443 /// A <see cref="System.Threading.Tasks.Task"/>, containing the result.
391444 /// The result is a <see cref="System.Collections.Generic.List{T}"/> of <see cref="WGetNET.WinGetPackage"/> instances.
@@ -397,12 +450,19 @@ public async Task<List<WinGetPackage>> GetInstalledPackagesAsync(string packageN
397450 /// The current action failed for an unexpected reason.
398451 /// Please see inner exception.
399452 /// </exception>
400- public async Task < List < WinGetPackage > > GetInstalledPackagesAsync ( string packageName , string sourceName )
453+ public async Task < List < WinGetPackage > > GetInstalledPackagesAsync ( string packageId , string sourceName , bool exact = false )
401454 {
402455 try
403456 {
457+ string cmd = string . Format ( _searchInstalledBySourceCmd , packageId , sourceName ) ;
458+
459+ if ( exact )
460+ {
461+ cmd += " --exact" ;
462+ }
463+
404464 ProcessResult result =
405- await _processManager . ExecuteWingetProcessAsync ( string . Format ( _searchInstalledBySourceCmd , packageName , sourceName ) ) ;
465+ await _processManager . ExecuteWingetProcessAsync ( cmd ) ;
406466
407467 return ProcessOutputReader . ToPackageList ( result . Output , PackageAction . InstalledListBySource , sourceName ) ;
408468 }
0 commit comments