40 lines
676 B
Plaintext
40 lines
676 B
Plaintext
edit:add-var archiver~ [@argv]{
|
|
use str
|
|
help = {
|
|
echo "Usage : archiver [(-zlxgb)] <file to compress>"
|
|
return
|
|
}
|
|
if (or (== (count $argv) 0) (eq $argv[0] -h)) {
|
|
$help
|
|
}
|
|
local:format = zst
|
|
local:o = $argv[0]
|
|
if (and (str:has-prefix $o -) (> (count $o) 1)) {
|
|
o = $o[1]
|
|
local:m = [
|
|
&z=zst
|
|
&l=lz4
|
|
&x=xz
|
|
&g=gz
|
|
&b=bz2
|
|
]
|
|
if (not (has-key $m $o)) {
|
|
$help
|
|
}
|
|
format = $m[$o]
|
|
argv = $argv[1..]
|
|
}
|
|
if (== (count $argv) 0) {
|
|
$help
|
|
}
|
|
peach [f]{
|
|
local:f = $f
|
|
if (eq $f[-1] /) {
|
|
f = $f[..-1]
|
|
}
|
|
e:arc archive $f'.tar.'$format $f
|
|
echo "'"$f"'" archivé
|
|
} $argv
|
|
}
|
|
|