mirror of
https://github.com/ScoopInstaller/Scoop.git
synced 2025-10-30 06:07:56 +00:00
refactor(output): Replace raw prints with functions for standardized output (#6449)
Co-authored-by: Hsiao-nan Cheung <niheaven@gmail.com>
This commit is contained in:
@@ -15,6 +15,10 @@
|
|||||||
- **scoop-version:** Fix logic error caused by missing brackets ([#6463](https://github.com/ScoopInstaller/Scoop/issues/6463))
|
- **scoop-version:** Fix logic error caused by missing brackets ([#6463](https://github.com/ScoopInstaller/Scoop/issues/6463))
|
||||||
- **core|manifest:** Avoid error messages when searching non-existent 'deprecated' directory ([#6471](https://github.com/ScoopInstaller/Scoop/issues/6471))
|
- **core|manifest:** Avoid error messages when searching non-existent 'deprecated' directory ([#6471](https://github.com/ScoopInstaller/Scoop/issues/6471))
|
||||||
|
|
||||||
|
### Code Refactoring
|
||||||
|
|
||||||
|
- **output**: Replace raw prints with functions for standardized output ([#6449](https://github.com/ScoopInstaller/Scoop/issues/6449))
|
||||||
|
|
||||||
## [v0.5.3](https://github.com/ScoopInstaller/Scoop/compare/v0.5.2...v0.5.3) - 2025-08-11
|
## [v0.5.3](https://github.com/ScoopInstaller/Scoop/compare/v0.5.2...v0.5.3) - 2025-08-11
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ function load_cfg($file) {
|
|||||||
$content = [System.IO.File]::ReadAllLines($file)
|
$content = [System.IO.File]::ReadAllLines($file)
|
||||||
return ($content | ConvertFrom-Json -ErrorAction Stop)
|
return ($content | ConvertFrom-Json -ErrorAction Stop)
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host "ERROR loading $file`: $($_.exception.message)"
|
error "loading $file`: $($_.exception.message)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ function ensure_install_dir_not_in_path($dir, $global) {
|
|||||||
|
|
||||||
$fixed, $removed = find_dir_or_subdir $path "$dir"
|
$fixed, $removed = find_dir_or_subdir $path "$dir"
|
||||||
if ($removed) {
|
if ($removed) {
|
||||||
$removed | ForEach-Object { "Installer added '$(friendly_path $_)' to path. Removing." }
|
$removed | ForEach-Object { Write-Output "Installer added '$(friendly_path $_)' to path. Removing." }
|
||||||
Set-EnvVar -Name 'PATH' -Value $fixed -Global:$global
|
Set-EnvVar -Name 'PATH' -Value $fixed -Global:$global
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ if ($SubCommand -notin $SubCommands) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$opt, $other, $err = getopt $Args 'v' 'verbose'
|
$opt, $other, $err = getopt $Args 'v' 'verbose'
|
||||||
if ($err) { "scoop alias: $err"; exit 1 }
|
if ($err) { error "scoop alias: $err"; exit 1 }
|
||||||
|
|
||||||
$name, $command, $description = $other
|
$name, $command, $description = $other
|
||||||
$verbose = $opt.v -or $opt.verbose
|
$verbose = $opt.v -or $opt.verbose
|
||||||
|
|||||||
@@ -34,14 +34,14 @@ $usage_rm = 'usage: scoop bucket rm <name>'
|
|||||||
switch ($cmd) {
|
switch ($cmd) {
|
||||||
'add' {
|
'add' {
|
||||||
if (!$name) {
|
if (!$name) {
|
||||||
'<name> missing'
|
error '<name> missing'
|
||||||
$usage_add
|
$usage_add
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
if (!$repo) {
|
if (!$repo) {
|
||||||
$repo = known_bucket_repo $name
|
$repo = known_bucket_repo $name
|
||||||
if (!$repo) {
|
if (!$repo) {
|
||||||
"Unknown bucket '$name'. Try specifying <repo>."
|
error "Unknown bucket '$name'. Try specifying <repo>."
|
||||||
$usage_add
|
$usage_add
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ switch ($cmd) {
|
|||||||
}
|
}
|
||||||
'rm' {
|
'rm' {
|
||||||
if (!$name) {
|
if (!$name) {
|
||||||
'<name> missing'
|
error '<name> missing'
|
||||||
$usage_rm
|
$usage_rm
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@@ -73,7 +73,7 @@ switch ($cmd) {
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
default {
|
default {
|
||||||
"scoop bucket: cmd '$cmd' not supported"
|
error "scoop bucket: cmd '$cmd' not supported"
|
||||||
my_usage
|
my_usage
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ function cacheshow($app) {
|
|||||||
|
|
||||||
function cacheremove($app) {
|
function cacheremove($app) {
|
||||||
if (!$app) {
|
if (!$app) {
|
||||||
'ERROR: <app(s)> missing'
|
error '<app(s)> missing'
|
||||||
my_usage
|
my_usage
|
||||||
exit 1
|
exit 1
|
||||||
} elseif ($app -eq '*' -or $app -eq '-a' -or $app -eq '--all') {
|
} elseif ($app -eq '*' -or $app -eq '-a' -or $app -eq '--all') {
|
||||||
|
|||||||
@@ -16,15 +16,15 @@
|
|||||||
. "$PSScriptRoot\..\lib\install.ps1" # persist related
|
. "$PSScriptRoot\..\lib\install.ps1" # persist related
|
||||||
|
|
||||||
$opt, $apps, $err = getopt $args 'agk' 'all', 'global', 'cache'
|
$opt, $apps, $err = getopt $args 'agk' 'all', 'global', 'cache'
|
||||||
if ($err) { "scoop cleanup: $err"; exit 1 }
|
if ($err) { error "scoop cleanup: $err"; exit 1 }
|
||||||
$global = $opt.g -or $opt.global
|
$global = $opt.g -or $opt.global
|
||||||
$cache = $opt.k -or $opt.cache
|
$cache = $opt.k -or $opt.cache
|
||||||
$all = $opt.a -or $opt.all
|
$all = $opt.a -or $opt.all
|
||||||
|
|
||||||
if (!$apps -and !$all) { 'ERROR: <app> missing'; my_usage; exit 1 }
|
if (!$apps -and !$all) { error '<app> missing'; my_usage; exit 1 }
|
||||||
|
|
||||||
if ($global -and !(is_admin)) {
|
if ($global -and !(is_admin)) {
|
||||||
'ERROR: you need admin rights to cleanup global apps'; exit 1
|
error 'you need admin rights to cleanup global apps'; exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup($app, $global, $verbose, $cache) {
|
function cleanup($app, $global, $verbose, $cache) {
|
||||||
|
|||||||
@@ -27,17 +27,17 @@ function print_summaries {
|
|||||||
|
|
||||||
$commands = commands
|
$commands = commands
|
||||||
|
|
||||||
if(!($cmd)) {
|
if (!($cmd)) {
|
||||||
Write-Host "Usage: scoop <command> [<args>]
|
Write-Host "Usage: scoop <command> [<args>]
|
||||||
|
|
||||||
Available commands are listed below.
|
Available commands are listed below.
|
||||||
|
|
||||||
Type 'scoop help <command>' to get more help for a specific command."
|
Type 'scoop help <command>' to get more help for a specific command."
|
||||||
print_summaries
|
print_summaries
|
||||||
} elseif($commands -contains $cmd) {
|
} elseif ($commands -contains $cmd) {
|
||||||
print_help $cmd
|
print_help $cmd
|
||||||
} else {
|
} else {
|
||||||
warn "scoop help: no such command '$cmd'"
|
error "scoop help: no such command '$cmd'"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
|
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
|
||||||
|
|
||||||
$opt, $apps, $err = getopt $args 'g' 'global'
|
$opt, $apps, $err = getopt $args 'g' 'global'
|
||||||
if ($err) { "scoop hold: $err"; exit 1 }
|
if ($err) { error "scoop hold: $err"; exit 1 }
|
||||||
|
|
||||||
$global = $opt.g -or $opt.global
|
$global = $opt.g -or $opt.global
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ if (get_config USE_SQLITE_CACHE) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$opt, $apps, $err = getopt $args 'giksua:' 'global', 'independent', 'no-cache', 'skip-hash-check', 'no-update-scoop', 'arch='
|
$opt, $apps, $err = getopt $args 'giksua:' 'global', 'independent', 'no-cache', 'skip-hash-check', 'no-update-scoop', 'arch='
|
||||||
if ($err) { "scoop install: $err"; exit 1 }
|
if ($err) { error "scoop install: $err"; exit 1 }
|
||||||
|
|
||||||
$global = $opt.g -or $opt.global
|
$global = $opt.g -or $opt.global
|
||||||
$check_hash = !($opt.s -or $opt.'skip-hash-check')
|
$check_hash = !($opt.s -or $opt.'skip-hash-check')
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ $global = installed_apps $true | ForEach-Object { @{ name = $_; global = $true }
|
|||||||
|
|
||||||
$apps = @($local) + @($global)
|
$apps = @($local) + @($global)
|
||||||
if (-not $apps) {
|
if (-not $apps) {
|
||||||
Write-Host "There aren't any apps installed."
|
warn "There aren't any apps installed."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ $apps | Where-Object { !$query -or ($_.name -match $query) } | ForEach-Object {
|
|||||||
$item.Updated = $updated
|
$item.Updated = $updated
|
||||||
|
|
||||||
$info = @()
|
$info = @()
|
||||||
if ((app_status $app $global).deprecated) { $info += 'Deprecated package'}
|
if ((app_status $app $global).deprecated) { $info += 'Deprecated package' }
|
||||||
if ($global) { $info += 'Global install' }
|
if ($global) { $info += 'Global install' }
|
||||||
if (failed $app $global) { $info += 'Install failed' }
|
if (failed $app $global) { $info += 'Install failed' }
|
||||||
if ($install_info.hold) { $info += 'Held package' }
|
if ($install_info.hold) { $info += 'Held package' }
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
. "$PSScriptRoot\..\lib\shortcuts.ps1"
|
. "$PSScriptRoot\..\lib\shortcuts.ps1"
|
||||||
|
|
||||||
$opt, $apps, $err = getopt $args 'a' 'all'
|
$opt, $apps, $err = getopt $args 'a' 'all'
|
||||||
if($err) { "scoop reset: $err"; exit 1 }
|
if($err) { error "scoop reset: $err"; exit 1 }
|
||||||
$all = $opt.a -or $opt.all
|
$all = $opt.a -or $opt.all
|
||||||
|
|
||||||
if(!$apps -and !$all) { error '<app> missing'; my_usage; exit 1 }
|
if(!$apps -and !$all) { error '<app> missing'; my_usage; exit 1 }
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ if ($SubCommand -notin @('add', 'rm', 'list', 'info', 'alter')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$opt, $other, $err = getopt $Args 'g' 'global'
|
$opt, $other, $err = getopt $Args 'g' 'global'
|
||||||
if ($err) { "scoop shim: $err"; exit 1 }
|
if ($err) { error "scoop shim: $err"; exit 1 }
|
||||||
|
|
||||||
$global = $opt.g -or $opt.global
|
$global = $opt.g -or $opt.global
|
||||||
|
|
||||||
@@ -147,8 +147,7 @@ switch ($SubCommand) {
|
|||||||
$pattern = $_
|
$pattern = $_
|
||||||
[void][Regex]::New($pattern)
|
[void][Regex]::New($pattern)
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host "ERROR: Invalid pattern: " -ForegroundColor Red -NoNewline
|
error "Invalid pattern: $([char]0x1b)[35m$pattern$([char]0x1b)[0m"
|
||||||
Write-Host $pattern -ForegroundColor Magenta
|
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
|
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
|
||||||
|
|
||||||
$opt, $apps, $err = getopt $args 'g' 'global'
|
$opt, $apps, $err = getopt $args 'g' 'global'
|
||||||
if ($err) { "scoop unhold: $err"; exit 1 }
|
if ($err) { error "scoop unhold: $err"; exit 1 }
|
||||||
|
|
||||||
$global = $opt.g -or $opt.global
|
$global = $opt.g -or $opt.global
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ if (get_config USE_SQLITE_CACHE) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$opt, $apps, $err = getopt $args 'gfiksqa' 'global', 'force', 'independent', 'no-cache', 'skip-hash-check', 'quiet', 'all'
|
$opt, $apps, $err = getopt $args 'gfiksqa' 'global', 'force', 'independent', 'no-cache', 'skip-hash-check', 'quiet', 'all'
|
||||||
if ($err) { "scoop update: $err"; exit 1 }
|
if ($err) { error "scoop update: $err"; exit 1 }
|
||||||
$global = $opt.g -or $opt.global
|
$global = $opt.g -or $opt.global
|
||||||
$force = $opt.f -or $opt.force
|
$force = $opt.f -or $opt.force
|
||||||
$check_hash = !($opt.s -or $opt.'skip-hash-check')
|
$check_hash = !($opt.s -or $opt.'skip-hash-check')
|
||||||
@@ -400,7 +400,7 @@ if (-not ($apps -or $all)) {
|
|||||||
success 'Scoop was updated successfully!'
|
success 'Scoop was updated successfully!'
|
||||||
} else {
|
} else {
|
||||||
if ($global -and !(is_admin)) {
|
if ($global -and !(is_admin)) {
|
||||||
'ERROR: You need admin rights to update global apps.'; exit 1
|
error 'You need admin rights to update global apps.'; exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
$outdated = @()
|
$outdated = @()
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
. "$PSScriptRoot\..\lib\depends.ps1" # 'Get-Dependency'
|
. "$PSScriptRoot\..\lib\depends.ps1" # 'Get-Dependency'
|
||||||
|
|
||||||
$opt, $apps, $err = getopt $args 'asnup' @('all', 'scan', 'no-depends', 'no-update-scoop', 'passthru')
|
$opt, $apps, $err = getopt $args 'asnup' @('all', 'scan', 'no-depends', 'no-update-scoop', 'passthru')
|
||||||
if ($err) { "scoop virustotal: $err"; exit 1 }
|
if ($err) { error "scoop virustotal: $err"; exit 1 }
|
||||||
$all = $apps -eq '*' -or $opt.a -or $opt.all
|
$all = $apps -eq '*' -or $opt.a -or $opt.all
|
||||||
if (!$apps -and !$all) { my_usage; exit 1 }
|
if (!$apps -and !$all) { my_usage; exit 1 }
|
||||||
$architecture = Get-DefaultArchitecture
|
$architecture = Get-DefaultArchitecture
|
||||||
|
|||||||
Reference in New Issue
Block a user