2021-10-13 18:43:40 +00:00
|
|
|
var cmd = $e:arc~
|
2021-08-27 19:45:39 +00:00
|
|
|
|
2021-12-11 21:09:02 +00:00
|
|
|
edit:add-var archiver~ {|@argv|
|
2021-08-24 18:44:01 +00:00
|
|
|
use str
|
2021-10-13 18:43:40 +00:00
|
|
|
var help = {
|
2020-03-13 14:03:36 +00:00
|
|
|
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
|
|
|
|
}
|
2021-08-27 19:45:39 +00:00
|
|
|
var format o = zst $argv[0]
|
2021-08-24 18:44:01 +00:00
|
|
|
if (and (str:has-prefix $o -) (> (count $o) 1)) {
|
2021-10-13 18:43:40 +00:00
|
|
|
set o = $o[1]
|
2021-08-27 19:45:39 +00:00
|
|
|
var m = [
|
2020-03-13 14:03:36 +00:00
|
|
|
&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
|
|
|
|
}
|
2021-10-13 18:43:40 +00:00
|
|
|
set format argv = $m[$o] $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
|
|
|
|
}
|
2021-12-11 21:09:02 +00:00
|
|
|
peach {|f|
|
2021-08-28 08:58:07 +00:00
|
|
|
var ff = $f
|
|
|
|
if (eq $ff[-1] /) {
|
2021-10-13 18:43:40 +00:00
|
|
|
set f = $ff[..-1]
|
2020-03-13 14:03:36 +00:00
|
|
|
}
|
2021-08-28 08:58:07 +00:00
|
|
|
$cmd archive $ff'.tar.'$format $ff
|
|
|
|
echo "'"$ff"'" 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
|
|
|
|
2021-12-11 21:09:02 +00:00
|
|
|
edit:add-var desarchiver~ {|@argv|
|
|
|
|
peach {|f|
|
2021-08-28 08:58:07 +00:00
|
|
|
var ff = $f
|
|
|
|
$cmd unarchive $ff
|
|
|
|
echo "'"$ff"'" désarchivé
|
2021-08-27 19:45:39 +00:00
|
|
|
} $argv
|
|
|
|
}
|
|
|
|
|
2021-12-11 21:09:02 +00:00
|
|
|
edit:add-var listarchiver~ {|@argv|
|
|
|
|
peach {|f|
|
2021-08-28 08:58:07 +00:00
|
|
|
var ff = $f
|
|
|
|
$cmd ls $ff
|
2021-08-27 19:45:39 +00:00
|
|
|
} $argv
|
|
|
|
}
|