winget-cli

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

AssertWinGetPackageManagerCmdlet.cs (1571B)


      1 // -----------------------------------------------------------------------------
      2 // <copyright file="AssertWinGetPackageManagerCmdlet.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.Management.Automation;
     10     using Microsoft.WinGet.Client.Commands.Common;
     11     using Microsoft.WinGet.Client.Common;
     12     using Microsoft.WinGet.Client.Engine.Commands;
     13 
     14     /// <summary>
     15     /// Assert-WinGetPackageManager. Verifies winget is installed properly.
     16     /// </summary>
     17     [Cmdlet(
     18         VerbsLifecycle.Assert,
     19         Constants.WinGetNouns.WinGetPackageManager,
     20         DefaultParameterSetName = Constants.IntegrityVersionSet)]
     21     [Alias("awgpm")]
     22     public class AssertWinGetPackageManagerCmdlet : WinGetPackageManagerCmdlet
     23     {
     24         /// <summary>
     25         /// Validates winget is installed correctly. If not, throws an exception
     26         /// with the reason why, if any.
     27         /// </summary>
     28         protected override void ProcessRecord()
     29         {
     30             var command = new WinGetPackageManagerCommand(this);
     31             if (this.ParameterSetName == Constants.IntegrityLatestSet)
     32             {
     33                 command.AssertUsingLatest(this.IncludePrerelease.ToBool());
     34             }
     35             else
     36             {
     37                 command.Assert(this.Version);
     38             }
     39         }
     40     }
     41 }