winget-cli

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

SetUserSettingCmdlet.cs (1794B)


      1 // -----------------------------------------------------------------------------
      2 // <copyright file="SetUserSettingCmdlet.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     /// Sets the specified user settings into the winget user settings. If the merge switch is on, merges current user
     16     /// settings with the input settings. Otherwise, overwrites the input settings.
     17     /// </summary>
     18     [Cmdlet(VerbsCommon.Set, Constants.WinGetNouns.UserSetting)]
     19     [Alias("swgus", "Set-WinGetUserSettings")]
     20     [OutputType(typeof(Hashtable))]
     21     public sealed class SetUserSettingCmdlet : PSCmdlet
     22     {
     23         /// <summary>
     24         /// Gets or sets the input user settings.
     25         /// </summary>
     26         [Parameter(
     27             Mandatory = true,
     28             ValueFromPipelineByPropertyName = true)]
     29         public Hashtable UserSettings { get; set; }
     30 
     31         /// <summary>
     32         /// Gets or sets a value indicating whether to merge the current user settings and the input settings.
     33         /// </summary>
     34         [Parameter(ValueFromPipelineByPropertyName = true)]
     35         public SwitchParameter Merge { get; set; }
     36 
     37         /// <summary>
     38         /// Process input of cmdlet.
     39         /// </summary>
     40         protected override void ProcessRecord()
     41         {
     42             var command = new UserSettingsCommand(this);
     43             command.Set(this.UserSettings, this.Merge.ToBool());
     44         }
     45     }
     46 }