2021-08-24 18:44:01 +00:00
|
|
|
edit:add-var archiver~ [@argv]{
|
|
|
|
use str
|
2020-03-13 14:03:36 +00:00
|
|
|
help = {
|
|
|
|
echo "Usage : archiver [(-zlxgb)] <file to compress>"
|
|
|
|
return
|
|
|
|
}
|
2021-08-24 18:44:01 +00:00
|
|
|
if (or (== (count $argv) 0) (eq $argv[0] -h)) {
|
2020-03-13 14:03:36 +00:00
|
|
|
$help
|
|
|
|
}
|
|
|
|
local:format = zst
|
2021-08-24 18:44:01 +00:00
|
|
|
local:o = $argv[0]
|
|
|
|
if (and (str:has-prefix $o -) (> (count $o) 1)) {
|
2020-03-13 14:03:36 +00:00
|
|
|
o = $o[1]
|
|
|
|
local:m = [
|
|
|
|
&z=zst
|
|
|
|
&l=lz4
|
|
|
|
&x=xz
|
2021-08-24 18:44:01 +00:00
|
|
|
&g=gz
|
2020-03-13 14:03:36 +00:00
|
|
|
&b=bz2
|
|
|
|
]
|
|
|
|
if (not (has-key $m $o)) {
|
|
|
|
$help
|
|
|
|
}
|
|
|
|
format = $m[$o]
|
2021-08-24 18:44:01 +00:00
|
|
|
argv = $argv[1..]
|
2020-03-13 14:03:36 +00:00
|
|
|
}
|
2021-08-24 18:44:01 +00:00
|
|
|
if (== (count $argv) 0) {
|
2020-03-13 14:03:36 +00:00
|
|
|
$help
|
|
|
|
}
|
|
|
|
peach [f]{
|
|
|
|
local:f = $f
|
|
|
|
if (eq $f[-1] /) {
|
2021-08-24 18:44:01 +00:00
|
|
|
f = $f[..-1]
|
2020-03-13 14:03:36 +00:00
|
|
|
}
|
|
|
|
e:arc archive $f'.tar.'$format $f
|
|
|
|
echo "'"$f"'" archivé
|
2021-08-24 18:44:01 +00:00
|
|
|
} $argv
|
2020-03-13 14:03:36 +00:00
|
|
|
}
|
2021-08-24 18:44:01 +00:00
|
|
|
|