commit ba552fdce16ba8d5f2a8f2e38f0eecc684d9a1f8
parent e50f66bd0dbbb67de168174e0c0569c8db8745c4
Author: Jeff Jerousek <jeff.jerousek@gmail.com>
Date: Wed, 16 Mar 2022 13:35:18 -0500
Function that will accept source agreement (#2020)
Diffstat:
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/tools/PowerShell/Microsoft.WinGet.Client/src/Library/Add-WinGetSource.ps1 b/tools/PowerShell/Microsoft.WinGet.Client/src/Library/Add-WinGetSource.ps1
@@ -32,7 +32,7 @@ Function Add-WinGetSource
This example adds a new source to the Windows Package Manager named "custom"
.EXAMPLE
- Add-WinGetSource -Name "custom" -Argument "https://contoso.com/" -Type "Microsoft.Rest" -Header "string"
+ Add-WinGetSource -Name "custom" -Argument "https://contoso.com/" -Type "Microsoft.Rest" -Header "string" -AcceptSourceAgreement:$true
This example adds a new source to the Windows Package Manager named "custom" and passes the value "string" in the Windows-Package-Manager HTTP header to the source.
#>
@@ -40,25 +40,24 @@ Function Add-WinGetSource
PARAM(
[Parameter(Mandatory=$true)] [string] $Name,
[Parameter(Mandatory=$true)] [string] $Argument,
- [Parameter(Mandatory=$true)] [ValidateSet("Microsoft.Rest", "Microsoft.PreIndexed.Package")] [string] $Type,
+ [Parameter(Mandatory=$true)] [ValidateSet("Microsoft.Rest", "Microsoft.PreIndexed.Package")] [string]$Type,
[Parameter()] [ValidateLength(1, 1024)] $Header,
- [Parameter()] [switch] $AcceptSourceAgreement
+ [Parameter()] [bool] $AcceptSourceAgreement
)
BEGIN
{
- [string[]] $WinGetArgs = "Source", "Add"
- $WinGetArgs += "--Name", $Name
- $WinGetArgs += "--Arg", $Argument
- $WinGetArgs += "--Type", $Type
+ if ($AcceptSourceAgreement) {$acceptOption = '--accept-source-agreements'}
+ [string] $WinGetArgs = "Source Add --Name {0} --Arg {1} --Type {2} {3}" -f $Name, $Argument, $Type, $acceptOption
}
PROCESS
{
- & "WinGet" $WingetArgs
+ Start-Process -FilePath "winget.exe" -ArgumentList $WinGetArgs -Wait
}
END
{
- return
+ #Don't do this unless you are in a class
+ #return
}
}
-Export-ModuleMember -Function Add-WinGetSource-
\ No newline at end of file
+Export-ModuleMember -Function Add-WinGetSource