106 lines
1.4 KiB
Plaintext
106 lines
1.4 KiB
Plaintext
use moi/util/condition
|
|
use moi/util/file
|
|
use moi/util/list
|
|
|
|
fn -local-packages { pacman -Q | eawk [_ p @_]{ put $p } }
|
|
|
|
fn -repo-packages {
|
|
local:packages = [(pacman -Ss | list:ploop &step=2 [_ v]{
|
|
put $v
|
|
} | eawk [_ p @_]{
|
|
put $p
|
|
})]
|
|
local:spackages = [&]
|
|
use str
|
|
peach [p]{
|
|
str:split '/' $p
|
|
} $packages | peach [e]{
|
|
spackages[$e] = $nil
|
|
}
|
|
keys $spackages
|
|
all $packages
|
|
}
|
|
|
|
fn -downloaded-packages [m]{
|
|
local:type = (condition:cset (eq $m '') prefix deep-prefix)
|
|
file:match-extensions &type=$type $m tar.zst tar.xz tar.gz tar.bz2
|
|
}
|
|
|
|
fn -local-file [m]{ edit:complete-filename $m }
|
|
|
|
options = [
|
|
-h
|
|
-V
|
|
-Q
|
|
-Qs
|
|
-Ql
|
|
-Qi
|
|
-Qm
|
|
-Qdt
|
|
-Qo
|
|
-R
|
|
-Rsn
|
|
-S
|
|
-Ss
|
|
-Si
|
|
-Sii
|
|
-Syu
|
|
-Syyu
|
|
-U
|
|
-D
|
|
]
|
|
|
|
asdeps = [
|
|
-S
|
|
-U
|
|
-D
|
|
]
|
|
|
|
lpack = [
|
|
-Q
|
|
-Qs
|
|
-Ql
|
|
-Qi
|
|
-D
|
|
-R
|
|
-Rsn
|
|
]
|
|
|
|
rpack = [
|
|
-S
|
|
-Ss
|
|
-Si
|
|
-Sii
|
|
]
|
|
|
|
dpack = [
|
|
-U
|
|
]
|
|
|
|
fpack = [
|
|
-Qo
|
|
]
|
|
|
|
fn complete [@argv]{
|
|
local:c = (count $argv)
|
|
if (< $c 3) {
|
|
all $options
|
|
} else {
|
|
local:cmd = $argv[1]
|
|
if (and (== $c 3) (has-value $asdeps $cmd)) {
|
|
put --asdeps --asexplicit
|
|
}
|
|
if (has-value $lpack $cmd) {
|
|
-local-packages
|
|
} elif (has-value $rpack $cmd) {
|
|
-repo-packages
|
|
} elif (has-value $dpack $cmd) {
|
|
-downloaded-packages $argv[-1]
|
|
} elif (has-value $fpack $cmd) {
|
|
-local-file $argv[-1]
|
|
}
|
|
}
|
|
}
|
|
|
|
edit:completion:arg-completer[pacman] = $complete~
|