-
Notifications
You must be signed in to change notification settings - Fork 15
/
gosk.go
58 lines (47 loc) · 848 Bytes
/
gosk.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
57
58
package main
import (
"flag"
"fmt"
"github.com/scottkiss/gosk"
"os"
)
const VERSION = "0.0.1"
const (
USAGE = `
gosk is a static site generator in Go
Usage:
gosk command [args...]
The commands are:
build build and generate site.
run[address:port] e.g. gosk run :80 (default listen at port 8080)
version print gosk version
`
)
var httpAddr = ":8080"
func main() {
flag.Parse()
args := flag.Args()
argsLength := len(args)
if argsLength == 0 || argsLength > 3 {
Usage()
os.Exit(1)
}
switch args[0] {
default:
Usage()
os.Exit(1)
case "build":
gosk.Build()
case "run":
if argsLength == 2 {
httpAddr = args[1]
}
fmt.Println("Listen at ", httpAddr)
gosk.Run(httpAddr)
case "version":
fmt.Print("gosk version " + VERSION)
}
}
func Usage() {
fmt.Println(USAGE)
}