summaryrefslogtreecommitdiff
path: root/cmd/cms/main.go
blob: 8f59cb2c4df1d0f8ff30c0f79fa0fa2516b720b8 (plain)
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"
	"os"
)

var usage = `
$ cms <option> <params>

Options: 
generate, gen, g:
    Generate a new content type file with boilerplate code to implement
    the editor.Editable interface. Must be given one (1) parameter of
    the name of the type for the new content.

    Example:
        $ cms gen Review

`

func init() {
	flag.Usage = func() {
		fmt.Println(usage)
	}
}

func main() {
	flag.Parse()

	args := flag.Args()
	if len(args) < 1 {
		flag.PrintDefaults()
		os.Exit(0)
	}

	fmt.Println(args)
	switch args[0] {
	case "generate", "gen", "g":
		if len(args) < 2 {
			flag.PrintDefaults()
			os.Exit(0)
		}

		name := args[1]

		err := generateContentType(name)
		if err != nil {
			fmt.Println(err)
			os.Exit(1)
		}
	case "serve", "s":
		serve()
	default:
		flag.PrintDefaults()
	}
}