forked from hzyitc/AmlImg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
56 lines (47 loc) · 1.01 KB
/
main.go
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
package main
import (
"os"
)
var version = "v0.0.0"
func usage() {
print(os.Args[0] + " (" + version + ")\n")
print("Usage:\n")
print(" " + os.Args[0] + " unpack <img path> <extract dir path>\n")
print(" " + os.Args[0] + " pack <img path> <dir path>\n")
print(" " + os.Args[0] + " res_unpack <img path> <extract dir path>\n")
print(" " + os.Args[0] + " res_pack <img path> <dir path>\n")
}
func main() {
if len(os.Args) != 4 {
usage()
os.Exit(1)
}
switch os.Args[1] {
case "unpack":
os.MkdirAll(os.Args[3], 0755)
err := unpack(os.Args[2], os.Args[3])
if err != nil {
println(err.Error())
os.Exit(1)
}
case "pack":
err := pack(os.Args[2], os.Args[3])
if err != nil {
println(err.Error())
os.Exit(1)
}
case "res_unpack":
os.MkdirAll(os.Args[3], 0755)
err := res_unpack(os.Args[2], os.Args[3])
if err != nil {
println(err.Error())
os.Exit(1)
}
case "res_pack":
err := res_pack(os.Args[2], os.Args[3])
if err != nil {
println(err.Error())
os.Exit(1)
}
}
}