-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
114 lines (97 loc) · 2.05 KB
/
Copy pathmain.go
File metadata and controls
114 lines (97 loc) · 2.05 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package main
import (
"flag"
"fmt"
"os"
)
func usageAsCheck() {
fmt.Printf("Usage: %s -f apkfile [-c check certification] [-l check locale] [-v check version]\n",
os.Args[0])
}
func usageAsPackZip() {
fmt.Printf("Usage: %s -d directory [-l filelist]\n",
os.Args[0])
}
/*
asPackzip let app acts as packzip
Usage:
$ packzip -d directory [-l filelist]
*/
func asPackzip() {
flag.Usage = usageAsPackZip
directory := flag.String("d", "", "directory to pack")
filelist := flag.String("l", "", "filelist")
flag.Parse()
args := flag.Args()
if len(args) != 0 {
fmt.Printf("Unknown argument: %v\n", args)
os.Exit(1)
}
// there's no -d argument or empty string directory
if *directory == "" {
flag.Usage()
os.Exit(1)
}
if _, err := os.Stat(*directory); os.IsNotExist(err) {
fmt.Println("directory doesn't exist")
os.Exit(1)
}
if *filelist != "" {
if _, err := os.Stat(*filelist); os.IsNotExist(err) {
fmt.Println("filelist doesn't exist")
os.Exit(1)
}
PackZip(*directory, *filelist)
}
}
func asCheck() {
/*
Usage:
$ check -c -l -v -f file.apk
-f apk filename
-c certification check
-l locale check
-v version format check
*/
flag.Usage = usageAsCheck
apkfile := flag.String("f", "", "apk filename")
checkcert := flag.Bool("c", false, "enable certification check")
checklocale := flag.Bool("l", false, "enable locale check")
checkversion := flag.Bool("v", false, "enable version check")
flag.Parse()
args := flag.Args()
if len(args) != 0 {
fmt.Printf("Unknown argument: %v\n", args)
os.Exit(1)
}
// there's no -d argument or empty string directory
if *apkfile == "" {
flag.Usage()
os.Exit(1)
}
if _, err := os.Stat(*apkfile); os.IsNotExist(err) {
fmt.Println("apk file doesn't exist")
os.Exit(1)
}
if *checkcert {
Checkcert("", "", "", "")
}
if *checklocale {
Checklocale()
}
if *checkversion {
Checkver()
}
if !*checkcert && !*checklocale && !*checkversion {
flag.Usage()
os.Exit(0)
}
}
func main() {
if os.Args[0] == "packzip" {
// if true {
asPackzip()
} else {
asCheck()
}
}