ResetSourceCmdlet.cs (1905B)
1 // ----------------------------------------------------------------------------- 2 // <copyright file="ResetSourceCmdlet.cs" company="Microsoft Corporation"> 3 // Copyright (c) Microsoft Corporation. Licensed under the MIT License. 4 // </copyright> 5 // ----------------------------------------------------------------------------- 6 7 namespace Microsoft.WinGet.Client.Cmdlets.Cmdlets 8 { 9 using System.Management.Automation; 10 using Microsoft.WinGet.Client.Common; 11 using Microsoft.WinGet.Client.Engine.Commands; 12 13 /// <summary> 14 /// Resets a source. Requires admin. 15 /// </summary> 16 [Cmdlet(VerbsCommon.Reset, Constants.WinGetNouns.Source, DefaultParameterSetName = Constants.DefaultSet)] 17 [Alias("rswgs")] 18 public sealed class ResetSourceCmdlet : PSCmdlet 19 { 20 /// <summary> 21 /// Gets or sets the name of the source to reset. 22 /// </summary> 23 [Parameter( 24 Position = 0, 25 Mandatory = true, 26 ParameterSetName = Constants.DefaultSet, 27 ValueFromPipeline = true, 28 ValueFromPipelineByPropertyName = true)] 29 public string Name { get; set; } 30 31 /// <summary> 32 /// Gets or sets a value indicating whether to reset all sources. 33 /// </summary> 34 [Parameter(ParameterSetName = Constants.OptionalSet, ValueFromPipelineByPropertyName = true)] 35 public SwitchParameter All { get; set; } 36 37 /// <summary> 38 /// Resets source. 39 /// </summary> 40 protected override void ProcessRecord() 41 { 42 var command = new CliCommand(this); 43 44 if (!string.IsNullOrEmpty(this.Name)) 45 { 46 command.ResetSourceByName(this.Name); 47 } 48 else if (this.All) 49 { 50 command.ResetAllSources(); 51 } 52 } 53 } 54 }