-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathval.v
61 lines (55 loc) · 1.03 KB
/
val.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
module main
import os
fn main() {
args := os.args[1..]
if args.len == 0 {
print_help()
return
}
mut rec := false
mut path := ''
mut out := ''
mut extr := false
mut compress := false
for i := 0; i < args.len; i++ {
arg := args[i]
match arg {
'-r' {
rec = true
}
'-e' {
extr = true
}
'-c' {
compress = true
}
'-p' {
path = args[i + 1]
i++
}
'-o' {
out = args[i + 1]
i++
}
else {
eprintln('Unkown flag `$arg`')
print_help()
return
}
}
}
if extr {
arch := create_from_file(path, compress)
arch.make_orginial(out)
} else {
arch := create_from_path(path, out, rec, compress)
arch.make_file()
}
}
fn print_help() {
eprintln('Usage:')
eprintln('val [(-r)/-e] -c -p <input path depends on action> -o <output path depends on action>')
eprintln(' -c Compression enabled (Optional)')
eprintln(' -r Activates recursion for archiving (Optional)')
eprintln(' -e If set action is set to extraction, if not set action is archiving')
}