From 13c01fda652b6c097f29437e6581bd81d1714fbe Mon Sep 17 00:00:00 2001 From: e2dk4r <43293320+e2dk4r@users.noreply.github.com> Date: Sat, 7 Dec 2024 13:33:24 +0300 Subject: [PATCH] custom-completions: scoop: improve code readablity Break getting scoop directories multiple lines to improve code readablity. --- custom-completions/scoop/scoop-completions.nu | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/custom-completions/scoop/scoop-completions.nu b/custom-completions/scoop/scoop-completions.nu index cc4ba948..9e9fc021 100644 --- a/custom-completions/scoop/scoop-completions.nu +++ b/custom-completions/scoop/scoop-completions.nu @@ -11,11 +11,19 @@ def scoopArches [] { # list of all installed apps def scoopInstalledApps [] { - let localAppDir = if ('SCOOP' in $env) { [$env.SCOOP, 'apps'] | path join } else { [$env.USERPROFILE, 'scoop', 'apps'] | path join } - let localApps = (ls $localAppDir | get name | path basename) - - let globalAppDir = if ('SCOOP_GLOBAL' in $env) { [$env.SCOOP_GLOBAL, 'apps'] | path join } else { [$env.ProgramData, 'scoop', 'apps'] | path join } - let globalApps = if ($globalAppDir | path exists) { ls $globalAppDir | get name | path basename } + let localAppDir = if ('SCOOP' in $env) { + [$env.SCOOP, 'apps'] | path join + } else { + [$env.USERPROFILE, 'scoop', 'apps'] | path join + } + let localApps = (ls $localAppDir | get name | path basename) + + let globalAppDir = if ('SCOOP_GLOBAL' in $env) { + [$env.SCOOP_GLOBAL, 'apps'] | path join + } else { + [$env.ProgramData, 'scoop', 'apps'] | path join + } + let globalApps = if ($globalAppDir | path exists) { ls $globalAppDir | get name | path basename } $localApps | append $globalApps } @@ -27,7 +35,11 @@ def scoopInstalledAppsWithStar [] { # list of all manifests from all buckets def scoopAllApps [] { - let bucketsDir = if ('SCOOP' in $env) { [ $env.SCOOP, 'buckets' ] | path join } else { [ $env.USERPROFILE, 'scoop', 'buckets' ] | path join } + let bucketsDir = if ('SCOOP' in $env) { + [ $env.SCOOP, 'buckets' ] | path join + } else { + [ $env.USERPROFILE, 'scoop', 'buckets' ] | path join + } (ls -s $bucketsDir | get name) | each {|bucket| ls ([$bucketsDir, $bucket, 'bucket', '*.json'] | path join ) | get name | path basename | str substring ..-5} | flatten | uniq } @@ -634,8 +646,13 @@ def scoopKnownBuckets [] { } def scoopInstalledBuckets [] { - let bucketsDir = if ('SCOOP' in (env).name) { [ (getenv 'SCOOP'), 'buckets' ] | path join } else { [ (getenv 'USERPROFILE'), 'scoop', 'buckets' ] | path join } - let buckets = (ls $bucketsDir | get name | path basename) + let bucketsDir = if ('SCOOP' in $env) { + [ $env.SCOOP, 'buckets' ] | path join + } else { + [ $env.USERPROFILE, 'scoop', 'buckets' ] | path join + } + + let buckets = (ls $bucketsDir | get name | path basename) $buckets }