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))
|
||||
- **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
|
||||
|
||||
### Features
|
||||
|
||||
@@ -90,7 +90,7 @@ function load_cfg($file) {
|
||||
$content = [System.IO.File]::ReadAllLines($file)
|
||||
return ($content | ConvertFrom-Json -ErrorAction Stop)
|
||||
} 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"
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ if ($SubCommand -notin $SubCommands) {
|
||||
}
|
||||
|
||||
$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
|
||||
$verbose = $opt.v -or $opt.verbose
|
||||
|
||||
@@ -34,14 +34,14 @@ $usage_rm = 'usage: scoop bucket rm <name>'
|
||||
switch ($cmd) {
|
||||
'add' {
|
||||
if (!$name) {
|
||||
'<name> missing'
|
||||
error '<name> missing'
|
||||
$usage_add
|
||||
exit 1
|
||||
}
|
||||
if (!$repo) {
|
||||
$repo = known_bucket_repo $name
|
||||
if (!$repo) {
|
||||
"Unknown bucket '$name'. Try specifying <repo>."
|
||||
error "Unknown bucket '$name'. Try specifying <repo>."
|
||||
$usage_add
|
||||
exit 1
|
||||
}
|
||||
@@ -51,7 +51,7 @@ switch ($cmd) {
|
||||
}
|
||||
'rm' {
|
||||
if (!$name) {
|
||||
'<name> missing'
|
||||
error '<name> missing'
|
||||
$usage_rm
|
||||
exit 1
|
||||
}
|
||||
@@ -73,7 +73,7 @@ switch ($cmd) {
|
||||
exit 0
|
||||
}
|
||||
default {
|
||||
"scoop bucket: cmd '$cmd' not supported"
|
||||
error "scoop bucket: cmd '$cmd' not supported"
|
||||
my_usage
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ function cacheshow($app) {
|
||||
|
||||
function cacheremove($app) {
|
||||
if (!$app) {
|
||||
'ERROR: <app(s)> missing'
|
||||
error '<app(s)> missing'
|
||||
my_usage
|
||||
exit 1
|
||||
} elseif ($app -eq '*' -or $app -eq '-a' -or $app -eq '--all') {
|
||||
|
||||
@@ -16,15 +16,15 @@
|
||||
. "$PSScriptRoot\..\lib\install.ps1" # persist related
|
||||
|
||||
$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
|
||||
$cache = $opt.k -or $opt.cache
|
||||
$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)) {
|
||||
'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) {
|
||||
|
||||
@@ -27,17 +27,17 @@ function print_summaries {
|
||||
|
||||
$commands = commands
|
||||
|
||||
if(!($cmd)) {
|
||||
if (!($cmd)) {
|
||||
Write-Host "Usage: scoop <command> [<args>]
|
||||
|
||||
Available commands are listed below.
|
||||
|
||||
Type 'scoop help <command>' to get more help for a specific command."
|
||||
print_summaries
|
||||
} elseif($commands -contains $cmd) {
|
||||
} elseif ($commands -contains $cmd) {
|
||||
print_help $cmd
|
||||
} else {
|
||||
warn "scoop help: no such command '$cmd'"
|
||||
error "scoop help: no such command '$cmd'"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
|
||||
|
||||
$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
|
||||
|
||||
|
||||
@@ -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='
|
||||
if ($err) { "scoop install: $err"; exit 1 }
|
||||
if ($err) { error "scoop install: $err"; exit 1 }
|
||||
|
||||
$global = $opt.g -or $opt.global
|
||||
$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)
|
||||
if (-not $apps) {
|
||||
Write-Host "There aren't any apps installed."
|
||||
warn "There aren't any apps installed."
|
||||
exit 1
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ $apps | Where-Object { !$query -or ($_.name -match $query) } | ForEach-Object {
|
||||
$item.Updated = $updated
|
||||
|
||||
$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 (failed $app $global) { $info += 'Install failed' }
|
||||
if ($install_info.hold) { $info += 'Held package' }
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
. "$PSScriptRoot\..\lib\shortcuts.ps1"
|
||||
|
||||
$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
|
||||
|
||||
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'
|
||||
if ($err) { "scoop shim: $err"; exit 1 }
|
||||
if ($err) { error "scoop shim: $err"; exit 1 }
|
||||
|
||||
$global = $opt.g -or $opt.global
|
||||
|
||||
@@ -147,8 +147,7 @@ switch ($SubCommand) {
|
||||
$pattern = $_
|
||||
[void][Regex]::New($pattern)
|
||||
} catch {
|
||||
Write-Host "ERROR: Invalid pattern: " -ForegroundColor Red -NoNewline
|
||||
Write-Host $pattern -ForegroundColor Magenta
|
||||
error "Invalid pattern: $([char]0x1b)[35m$pattern$([char]0x1b)[0m"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
. "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion'
|
||||
|
||||
$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
|
||||
|
||||
|
||||
@@ -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'
|
||||
if ($err) { "scoop update: $err"; exit 1 }
|
||||
if ($err) { error "scoop update: $err"; exit 1 }
|
||||
$global = $opt.g -or $opt.global
|
||||
$force = $opt.f -or $opt.force
|
||||
$check_hash = !($opt.s -or $opt.'skip-hash-check')
|
||||
@@ -400,7 +400,7 @@ if (-not ($apps -or $all)) {
|
||||
success 'Scoop was updated successfully!'
|
||||
} else {
|
||||
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 = @()
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
. "$PSScriptRoot\..\lib\depends.ps1" # 'Get-Dependency'
|
||||
|
||||
$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
|
||||
if (!$apps -and !$all) { my_usage; exit 1 }
|
||||
$architecture = Get-DefaultArchitecture
|
||||
|
||||
Reference in New Issue
Block a user