-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (37 loc) · 1000 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
package main
import (
"fmt"
"os"
"github.com/PhilippReinke/blogmd/args"
"github.com/PhilippReinke/blogmd/project"
"github.com/alexflint/go-arg"
)
func main() {
var args args.Args
arg.MustParse(&args)
switch {
case args.Build != nil:
project := project.NewExistingProject(args.Build.Path)
if err := project.Build(); err != nil {
fmt.Println("Could not build project:", err)
os.Exit(1)
}
case args.New != nil:
if err := project.Create(args.New.Path); err != nil {
fmt.Println("Could not create new project:", err)
os.Exit(1)
}
case args.Serve != nil:
project := project.NewExistingProject(args.Serve.Path)
if err := project.Serve(args.Serve.OpenInBrowser, args.Serve.Watch); err != nil {
fmt.Println("Could not serve project:", err)
os.Exit(1)
}
case args.Post != nil:
project := project.NewExistingProject("")
if err := project.CreatePost(args.Post.Title); err != nil {
fmt.Println("Could not create new post:", err)
os.Exit(1)
}
}
}