Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(scoop-install): Present --parameters parameter for custom installation options #98

Draft
wants to merge 8 commits into
base: NEW
Choose a base branch
from
13 changes: 12 additions & 1 deletion lib/getopt.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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) {
Expand Down Expand Up @@ -71,5 +82,5 @@ function Resolve-GetOpt($argv, $shortopts, $longopts) {
}
}

return $opts, $rem
return $opts, $rem, $null, $customOptions
}
7 changes: 6 additions & 1 deletion libexec/scoop-install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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
Expand Down