39 lines
689 B
Plaintext
39 lines
689 B
Plaintext
|
#alias:new archiver e:archiver
|
||
|
fn archiver [@_args]{
|
||
|
help = {
|
||
|
echo "Usage : archiver [(-zlxgb)] <file to compress>"
|
||
|
return
|
||
|
}
|
||
|
if (or (== (count $_args) 0) (eq $_args[0] -h)) {
|
||
|
$help
|
||
|
}
|
||
|
local:format = zst
|
||
|
local:o = $_args[0]
|
||
|
if (and (has-prefix $o -) (> (count $o) 1)) {
|
||
|
o = $o[1]
|
||
|
local:m = [
|
||
|
&z=zst
|
||
|
&l=lz4
|
||
|
&x=xz
|
||
|
&g=gzip
|
||
|
&b=bz2
|
||
|
]
|
||
|
if (not (has-key $m $o)) {
|
||
|
$help
|
||
|
}
|
||
|
format = $m[$o]
|
||
|
_args = $_args[1:]
|
||
|
}
|
||
|
if (== (count $_args) 0) {
|
||
|
$help
|
||
|
}
|
||
|
peach [f]{
|
||
|
local:f = $f
|
||
|
if (eq $f[-1] /) {
|
||
|
f = $f[:-1]
|
||
|
}
|
||
|
e:arc archive $f'.tar.'$format $f
|
||
|
echo "'"$f"'" archivé
|
||
|
} $_args
|
||
|
}
|