FinderCmdlet.cs (2867B)
1 // ----------------------------------------------------------------------------- 2 // <copyright file="FinderCmdlet.cs" company="Microsoft Corporation"> 3 // Copyright (c) Microsoft Corporation. Licensed under the MIT License. 4 // </copyright> 5 // ----------------------------------------------------------------------------- 6 7 namespace Microsoft.WinGet.Client.Commands.Common 8 { 9 using System.Management.Automation; 10 using Microsoft.WinGet.Client.Common; 11 using Microsoft.WinGet.Client.PSObjects; 12 13 /// <summary> 14 /// This is the base class for all commands that might need to search for a package. It contains an initial 15 /// set of parameters that corresponds to the intersection of i.e., the "install" and "search" commands. 16 /// </summary> 17 public abstract class FinderCmdlet : PSCmdlet 18 { 19 /// <summary> 20 /// Gets or sets the field that is matched against the identifier of a package. 21 /// </summary> 22 [Parameter( 23 ParameterSetName = Constants.FoundSet, 24 ValueFromPipelineByPropertyName = true)] 25 public string Id { get; set; } 26 27 /// <summary> 28 /// Gets or sets the field that is matched against the name of a package. 29 /// </summary> 30 [Parameter( 31 ParameterSetName = Constants.FoundSet, 32 ValueFromPipelineByPropertyName = true)] 33 public string Name { get; set; } 34 35 /// <summary> 36 /// Gets or sets the field that is matched against the moniker of a package. 37 /// </summary> 38 [Parameter( 39 ParameterSetName = Constants.FoundSet, 40 ValueFromPipelineByPropertyName = true)] 41 public string Moniker { get; set; } 42 43 /// <summary> 44 /// Gets or sets the name of the source to search for packages. If null, then all sources are searched. 45 /// </summary> 46 [Parameter( 47 ParameterSetName = Constants.FoundSet, 48 ValueFromPipelineByPropertyName = true)] 49 public string Source { get; set; } 50 51 /// <summary> 52 /// Gets or sets the strings that match against every field of a package. 53 /// </summary> 54 [Parameter( 55 ParameterSetName = Constants.FoundSet, 56 Position = 0, 57 ValueFromPipelineByPropertyName = true, 58 ValueFromRemainingArguments = true)] 59 public string[] Query { get; set; } 60 61 /// <summary> 62 /// Gets or sets how to match against package fields. Default ContainsCaseInsensitive. 63 /// </summary> 64 [Parameter( 65 ParameterSetName = Constants.FoundSet, 66 ValueFromPipelineByPropertyName = true)] 67 public PSPackageFieldMatchOption MatchOption { get; set; } = PSPackageFieldMatchOption.ContainsCaseInsensitive; 68 } 69 }