diff --git a/lib/getopt.ps1 b/lib/getopt.ps1 index 1faa74bb27..afbb393915 100644 --- a/lib/getopt.ps1 +++ b/lib/getopt.ps1 @@ -19,6 +19,7 @@ function Resolve-GetOpt($argv, $shortopts, $longopts) { # Ensure these are arrays $argv = @($argv) $longopts = @($longopts) + $customOptions = [Ordered] @{ } for ($i = 0; $i -lt $argv.length; $i++) { $arg = $argv[$i] @@ -33,6 +34,16 @@ function Resolve-GetOpt($argv, $shortopts, $longopts) { if ($arg.startswith('--')) { $name = $arg.substring(2) + if ($name -eq 'parameters') { + # Get only provided parameters + $special = $argv[($i + 1)..($argv.Length - 1)] + foreach ($sp in $special) { + $key, $value = $sp -split '=' + $customOptions.Add($key.ToLower(), $value) + } + break + } + $longopt = $longopts | Where-Object { $_ -match "^$name=?$" } if ($longopt) { @@ -71,5 +82,5 @@ function Resolve-GetOpt($argv, $shortopts, $longopts) { } } - return $opts, $rem + return $opts, $rem, $null, $customOptions } diff --git a/libexec/scoop-install.ps1 b/libexec/scoop-install.ps1 index 39f60eb6bd..71c8dca391 100644 --- a/libexec/scoop-install.ps1 +++ b/libexec/scoop-install.ps1 @@ -11,13 +11,16 @@ # scoop install D:\path\to\app.json # scoop install ./install/pwsh.json # -# Options: +# To install an app from a manifest using specific options +# scoop install vscode --parameters 'CONTEXT=1' 'FULLPORTABLE=1' +# # -h, --help Show help for this command. # -a, --arch <32bit|64bit|arm64> Use the specified architecture, if the application's manifest supports it. # -g, --global Install the application(s) globally. # -i, --independent Do not install dependencies automatically. # -k, --no-cache Do not use the download cache. # -s, --skip Skip hash validation (use with caution!). +# -p, --parameters Manifest specific parameters (KEY=VALUE). Hash to be always last option @( @('core', 'Test-ScoopDebugEnabled'), @@ -78,6 +81,8 @@ function is_installed($app, $global, $version) { $opt, $apps, $err = Resolve-GetOpt $args 'giksa:' 'global', 'independent', 'no-cache', 'skip', 'arch=' if ($err) { Stop-ScoopExecution -Message "scoop install: $err" -ExitCode 2 } +# Write-Host $configOptions.beta +# exit 0 $exitCode = 0 $problems = 0 $global = $opt.g -or $opt.global