-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
62 lines (52 loc) · 1021 Bytes
/
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
57
58
59
60
61
62
package main
import (
"fmt"
"os"
"text/template"
)
const (
baseFile = "base.html"
extHTML = "html"
extMarkdown = "md"
version = 1 // Arbitrary right now
)
var (
baseTemplate *template.Template
validExts = []string{extHTML, extMarkdown}
pages = []Page{}
latestPages []Page // Cached
)
var help = `Please use grumpo like:
grumpo
To see the version and this message
grumpo <cmd> <space separated flags>
Where cmd could be: gen|init|local
Flags could be -nohtmlpretty|-nohtmlvalidate
`
func die(f string, args ...interface{}) {
msg := fmt.Sprintf("Error: "+f+"\n", args...)
panic(msg)
// os.Exit(1)
}
func helpDie() {
fmt.Printf(help)
os.Exit(0)
}
// TODO create init command that will require an empty starting dir
func main() {
if len(os.Args) == 1 { // Running just grumpo
fmt.Printf("Grumpo version %d\n", version)
helpDie()
}
cmd := os.Args[1]
switch cmd {
case "gen":
gen()
case "init":
initNewProj()
case "local":
local()
default:
helpDie()
}
}