2020-03-13 14:03:36 +00:00
|
|
|
use moi/util/condition
|
|
|
|
use moi/util/file
|
|
|
|
use moi/util/list
|
|
|
|
|
|
|
|
fn -local-packages { pacman -Q | eawk [_ p @_]{ put $p } }
|
|
|
|
|
|
|
|
fn -repo-packages {
|
2021-08-27 20:06:49 +00:00
|
|
|
var packages = [(pacman -Ss | list:ploop &step=2 [_ v]{
|
2020-03-13 14:03:36 +00:00
|
|
|
put $v
|
|
|
|
} | eawk [_ p @_]{
|
|
|
|
put $p
|
|
|
|
})]
|
2021-08-27 20:06:49 +00:00
|
|
|
var spackages = [&]
|
2020-07-22 09:24:43 +00:00
|
|
|
use str
|
2020-03-13 14:03:36 +00:00
|
|
|
peach [p]{
|
2020-07-22 09:24:43 +00:00
|
|
|
str:split '/' $p
|
2020-03-13 14:03:36 +00:00
|
|
|
} $packages | peach [e]{
|
2021-10-13 18:49:48 +00:00
|
|
|
set spackages[$e] = $nil
|
2020-03-13 14:03:36 +00:00
|
|
|
}
|
|
|
|
keys $spackages
|
2020-07-22 09:24:43 +00:00
|
|
|
all $packages
|
2020-03-13 14:03:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn -downloaded-packages [m]{
|
2021-08-27 20:06:49 +00:00
|
|
|
var type = (condition:cset (eq $m '') prefix deep-prefix)
|
2020-03-13 14:03:36 +00:00
|
|
|
file:match-extensions &type=$type $m tar.zst tar.xz tar.gz tar.bz2
|
|
|
|
}
|
|
|
|
|
|
|
|
fn -local-file [m]{ edit:complete-filename $m }
|
|
|
|
|
2021-08-27 20:06:49 +00:00
|
|
|
var options = [
|
2020-03-13 14:03:36 +00:00
|
|
|
-h
|
|
|
|
-V
|
|
|
|
-Q
|
|
|
|
-Qs
|
|
|
|
-Ql
|
|
|
|
-Qi
|
|
|
|
-Qm
|
|
|
|
-Qdt
|
|
|
|
-Qo
|
|
|
|
-R
|
|
|
|
-Rsn
|
|
|
|
-S
|
|
|
|
-Ss
|
|
|
|
-Si
|
|
|
|
-Sii
|
|
|
|
-Syu
|
|
|
|
-Syyu
|
|
|
|
-U
|
|
|
|
-D
|
|
|
|
]
|
|
|
|
|
2021-08-27 20:06:49 +00:00
|
|
|
var asdeps = [
|
2020-03-13 14:03:36 +00:00
|
|
|
-S
|
|
|
|
-U
|
|
|
|
-D
|
|
|
|
]
|
|
|
|
|
2021-08-27 20:06:49 +00:00
|
|
|
var lpack = [
|
2020-03-13 14:03:36 +00:00
|
|
|
-Q
|
|
|
|
-Qs
|
|
|
|
-Ql
|
|
|
|
-Qi
|
|
|
|
-D
|
|
|
|
-R
|
|
|
|
-Rsn
|
|
|
|
]
|
|
|
|
|
2021-08-27 20:06:49 +00:00
|
|
|
var rpack = [
|
2020-03-13 14:03:36 +00:00
|
|
|
-S
|
|
|
|
-Ss
|
|
|
|
-Si
|
|
|
|
-Sii
|
|
|
|
]
|
|
|
|
|
2021-08-27 20:06:49 +00:00
|
|
|
var dpack = [
|
2020-03-13 14:03:36 +00:00
|
|
|
-U
|
|
|
|
]
|
|
|
|
|
2021-08-27 20:06:49 +00:00
|
|
|
var fpack = [
|
2020-03-13 14:03:36 +00:00
|
|
|
-Qo
|
|
|
|
]
|
|
|
|
|
|
|
|
fn complete [@argv]{
|
2021-08-27 20:06:49 +00:00
|
|
|
var c = (count $argv)
|
2020-03-13 14:03:36 +00:00
|
|
|
if (< $c 3) {
|
2020-07-22 09:24:43 +00:00
|
|
|
all $options
|
2020-03-13 14:03:36 +00:00
|
|
|
} else {
|
2021-08-27 20:06:49 +00:00
|
|
|
var cmd = $argv[1]
|
2020-03-13 14:03:36 +00:00
|
|
|
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]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-13 18:49:48 +00:00
|
|
|
set edit:completion:arg-completer[pacman] = $complete~
|