Skip to content

Commit

Permalink
custom-completions: scoop: improve code readablity
Browse files Browse the repository at this point in the history
Break getting scoop directories multiple lines to improve code
readablity.
  • Loading branch information
e2dk4r committed Dec 7, 2024
1 parent 6c9f974 commit 13c01fd
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions custom-completions/scoop/scoop-completions.nu
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 13c01fd

Please sign in to comment.