winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

TestUserSettingCmdlet.cs (1721B)


      1 // -----------------------------------------------------------------------------
      2 // <copyright file="TestUserSettingCmdlet.cs" company="Microsoft Corporation">
      3 //     Copyright (c) Microsoft Corporation. Licensed under the MIT License.
      4 // </copyright>
      5 // -----------------------------------------------------------------------------
      6 
      7 namespace Microsoft.WinGet.Client.Commands
      8 {
      9     using System.Collections;
     10     using System.Management.Automation;
     11     using Microsoft.WinGet.Client.Common;
     12     using Microsoft.WinGet.Client.Engine.Commands;
     13 
     14     /// <summary>
     15     /// Compare the specified user settings with the winget user settings.
     16     /// </summary>
     17     [Cmdlet(VerbsDiagnostic.Test, Constants.WinGetNouns.UserSetting)]
     18     [Alias("twgus", "Test-WinGetUserSettings")]
     19     [OutputType(typeof(bool))]
     20     public sealed class TestUserSettingCmdlet : PSCmdlet
     21     {
     22         /// <summary>
     23         /// Gets or sets the input user settings.
     24         /// </summary>
     25         [Parameter(
     26             Mandatory = true,
     27             ValueFromPipelineByPropertyName = true)]
     28         public Hashtable UserSettings { get; set; }
     29 
     30         /// <summary>
     31         /// Gets or sets a value indicating whether to ignore comparing settings that are not part of the input.
     32         /// </summary>
     33         [Parameter(ValueFromPipelineByPropertyName = true)]
     34         public SwitchParameter IgnoreNotSet { get; set; }
     35 
     36         /// <summary>
     37         /// Process the cmdlet and writes the result of the comparison.
     38         /// </summary>
     39         protected override void ProcessRecord()
     40         {
     41             var command = new UserSettingsCommand(this);
     42             command.Test(this.UserSettings, this.IgnoreNotSet.ToBool());
     43         }
     44     }
     45 }