forked from sipin/gorazor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgorazor.go
52 lines (44 loc) · 899 Bytes
/
gorazor.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
package main
// considering import fsnotify
import (
"flag"
"fmt"
"os"
"github.com/sipin/gorazor/gorazor"
)
func Usage() {
fmt.Fprintf(os.Stderr, "usage: gorazor [input dir or file] [output dir or file]\n")
flag.PrintDefaults()
os.Exit(2)
}
func main() {
debug := false
flag.Usage = Usage
flag.Parse()
options := gorazor.Option{}
if debug {
options["Debug"] = true
}
if flag.NArg() == 2 {
arg1, arg2 := flag.Arg(0), flag.Arg(1)
stat, err := os.Stat(arg1)
if err != nil {
fmt.Println(err)
os.Exit(2)
}
if stat.IsDir() {
fmt.Printf("Processing dir: %s %s\n", arg1, arg2)
err := gorazor.GenFolder(arg1, arg2, options)
if err != nil {
fmt.Println(err)
}
} else if stat.Mode().IsRegular() {
fmt.Printf("Processing file: %s %s\n", arg1, arg2)
gorazor.GenFile(arg1, arg2, options)
} else {
flag.Usage()
}
} else {
flag.Usage()
}
}