winget-cli

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

WindowsPackageManager.psm1 (6963B)


      1 # Module created by Microsoft.PowerShell.Crescendo
      2 class PowerShellCustomFunctionAttribute : System.Attribute { 
      3     [bool]$RequiresElevation
      4     [string]$Source
      5     PowerShellCustomFunctionAttribute() { $this.RequiresElevation = $false; $this.Source = "Microsoft.PowerShell.Crescendo" }
      6     PowerShellCustomFunctionAttribute([bool]$rElevation) {
      7         $this.RequiresElevation = $rElevation
      8         $this.Source = "Microsoft.PowerShell.Crescendo"
      9     }
     10 }
     11 
     12 
     13 
     14 function Get-WinGetVersion
     15 {
     16 [PowerShellCustomFunctionAttribute(RequiresElevation=$False)]
     17 [CmdletBinding()]
     18 
     19 param(    )
     20 
     21 BEGIN {
     22     $__PARAMETERMAP = @{}
     23     $__outputHandlers = @{
     24         default = @{ StreamOutput = $True; Handler = { $Input.trimstart('v') -as [version] } }
     25     }
     26 }
     27 
     28 PROCESS {
     29     $__commandArgs = @(
     30         '--version'
     31     )
     32     $__boundparms = $PSBoundParameters
     33     $MyInvocation.MyCommand.Parameters.Values.Where({$_.SwitchParameter -and $_.Name -notmatch "Debug|Whatif|Confirm|Verbose" -and ! $PSBoundParameters[$_.Name]}).ForEach({$PSBoundParameters[$_.Name] = [switch]::new($false)})
     34     if ($PSBoundParameters["Debug"]){wait-debugger}
     35     foreach ($paramName in $PSBoundParameters.Keys|Sort-Object {$__PARAMETERMAP[$_].OriginalPosition}) {
     36         $value = $PSBoundParameters[$paramName]
     37         $param = $__PARAMETERMAP[$paramName]
     38         if ($param) {
     39             if ( $value -is [switch] ) { $__commandArgs += if ( $value.IsPresent ) { $param.OriginalName } else { $param.DefaultMissingValue } }
     40             elseif ( $param.NoGap ) { $__commandArgs += "{0}""{1}""" -f $param.OriginalName, $value }
     41             else { $__commandArgs += $param.OriginalName; $__commandArgs += $value |Foreach-Object {$_}}
     42         }
     43     }
     44     $__commandArgs = $__commandArgs|Where-Object {$_}
     45     if ($PSBoundParameters["Debug"]){wait-debugger}
     46     if ( $PSBoundParameters["Verbose"]) {
     47          Write-Verbose -Verbose -Message winget
     48          $__commandArgs | Write-Verbose -Verbose
     49     }
     50     $__handlerInfo = $__outputHandlers[$PSCmdlet.ParameterSetName]
     51     if (! $__handlerInfo ) {
     52         $__handlerInfo = $__outputHandlers["Default"] # Guaranteed to be present
     53     }
     54     $__handler = $__handlerInfo.Handler
     55     if ( $PSCmdlet.ShouldProcess("winget $__commandArgs")) {
     56         if ( $__handlerInfo.StreamOutput ) {
     57             & "winget" $__commandArgs | & $__handler
     58         }
     59         else {
     60             $result = & "winget" $__commandArgs
     61             & $__handler $result
     62         }
     63     }
     64   } # end PROCESS
     65 
     66 <#
     67 .SYNOPSIS
     68 Windows Package Manager v1.1.12702
     69 Copyright (c) Microsoft Corporation. All rights reserved.
     70 
     71 The winget command line utility enables installing applications and other packages from the command line.
     72 
     73 usage: winget [<command>] [<options>]
     74 
     75 The following commands are available:
     76   install    Installs the given package
     77   show       Shows information about a package
     78   source     Manage sources of packages
     79   search     Find and show basic info of packages
     80   list       Display installed packages
     81   upgrade    Upgrades the given package
     82   uninstall  Uninstalls the given package
     83   hash       Helper to hash installer files
     84   validate   Validates a manifest file
     85   settings   Open settings or set administrator settings
     86   features   Shows the status of experimental features
     87   export     Exports a list of the installed packages
     88   import     Installs all the packages in a file
     89 
     90 For more details on a specific command, pass it the help argument. [-?]
     91 
     92 The following options are available:
     93   -v,--version  Display the version of the tool
     94   --info        Display general info of the tool
     95 
     96 More help can be found at: https://aka.ms/winget-command-help
     97 
     98 .DESCRIPTION See help for winget
     99 
    100 #>
    101 }
    102 
    103 
    104 
    105 
    106 function Get-WinGetSource
    107 {
    108 [PowerShellCustomFunctionAttribute(RequiresElevation=$False)]
    109 [CmdletBinding()]
    110 
    111 param(    )
    112 
    113 BEGIN {
    114     $__PARAMETERMAP = @{}
    115     $__outputHandlers = @{
    116         default = @{ StreamOutput = $True; Handler = { $Input | ConvertFrom-Json | add-member -pass -typename WinGetSource } }
    117     }
    118 }
    119 
    120 PROCESS {
    121     $__commandArgs = @(
    122         'source'
    123         'export'
    124     )
    125     $__boundparms = $PSBoundParameters
    126     $MyInvocation.MyCommand.Parameters.Values.Where({$_.SwitchParameter -and $_.Name -notmatch "Debug|Whatif|Confirm|Verbose" -and ! $PSBoundParameters[$_.Name]}).ForEach({$PSBoundParameters[$_.Name] = [switch]::new($false)})
    127     if ($PSBoundParameters["Debug"]){wait-debugger}
    128     foreach ($paramName in $PSBoundParameters.Keys|Sort-Object {$__PARAMETERMAP[$_].OriginalPosition}) {
    129         $value = $PSBoundParameters[$paramName]
    130         $param = $__PARAMETERMAP[$paramName]
    131         if ($param) {
    132             if ( $value -is [switch] ) { $__commandArgs += if ( $value.IsPresent ) { $param.OriginalName } else { $param.DefaultMissingValue } }
    133             elseif ( $param.NoGap ) { $__commandArgs += "{0}""{1}""" -f $param.OriginalName, $value }
    134             else { $__commandArgs += $param.OriginalName; $__commandArgs += $value |Foreach-Object {$_}}
    135         }
    136     }
    137     $__commandArgs = $__commandArgs|Where-Object {$_}
    138     if ($PSBoundParameters["Debug"]){wait-debugger}
    139     if ( $PSBoundParameters["Verbose"]) {
    140          Write-Verbose -Verbose -Message winget
    141          $__commandArgs | Write-Verbose -Verbose
    142     }
    143     $__handlerInfo = $__outputHandlers[$PSCmdlet.ParameterSetName]
    144     if (! $__handlerInfo ) {
    145         $__handlerInfo = $__outputHandlers["Default"] # Guaranteed to be present
    146     }
    147     $__handler = $__handlerInfo.Handler
    148     if ( $PSCmdlet.ShouldProcess("winget $__commandArgs")) {
    149         if ( $__handlerInfo.StreamOutput ) {
    150             & "winget" $__commandArgs | & $__handler
    151         }
    152         else {
    153             $result = & "winget" $__commandArgs
    154             & $__handler $result
    155         }
    156     }
    157   } # end PROCESS
    158 
    159 <#
    160 .SYNOPSIS
    161 Windows Package Manager v1.1.12702
    162 Copyright (c) Microsoft Corporation. All rights reserved.
    163 
    164 The winget command line utility enables installing applications and other packages from the command line.
    165 
    166 usage: winget [<command>] [<options>]
    167 
    168 The following commands are available:
    169   install    Installs the given package
    170   show       Shows information about a package
    171   source     Manage sources of packages
    172   search     Find and show basic info of packages
    173   list       Display installed packages
    174   upgrade    Upgrades the given package
    175   uninstall  Uninstalls the given package
    176   hash       Helper to hash installer files
    177   validate   Validates a manifest file
    178   settings   Open settings or set administrator settings
    179   features   Shows the status of experimental features
    180   export     Exports a list of the installed packages
    181   import     Installs all the packages in a file
    182 
    183 For more details on a specific command, pass it the help argument. [-?]
    184 
    185 The following options are available:
    186   -v,--version  Display the version of the tool
    187   --info        Display general info of the tool
    188 
    189 More help can be found at: https://aka.ms/winget-command-help
    190 
    191 .DESCRIPTION See help for winget
    192 
    193 #>
    194 }
    195 
    196