summaryrefslogtreecommitdiff
path: root/cmd/root.go
blob: 3ef07bc178e8fdcd025d492634c42b80e3c261ab (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
59
60
61
62
63
64
65
66
67
68
69
package cmd

import (
	"fmt"
	"os"

	"github.com/HimanshuSardana/kite/internal/build"
)

const (
	DefaultTheme = "modern-light"
	DefaultPort  = "8000"
)

func Execute() {
	args := os.Args
	if len(args) < 2 {
		build.ShowHelpMessage()
		return
	}

	switch args[1] {
	case "build":
		runBuild(args)
	case "serve":
		runServe(args)
	case "list-themes":
		runListThemes(args)
	case "init":
		runInit(args)
	default:
		build.ShowHelpMessage()
	}
}

func runInit(args []string) {
	if err := RunInit(); err != nil {
		fmt.Fprintf(os.Stderr, "Error: %v\n", err)
		os.Exit(1)
	}
}

func ShowHelp() {
	fmt.Println(`
Kite — A lightweight static site generator

USAGE:
  kite <command> [options]

COMMANDS:
  build         Build the static site into the output directory
  serve         Start a local development server with live reload
  list-themes   List all available themes
  init          Initialize a new blog project

OPTIONS:
  -h, --help    Show this help message

EXAMPLES:
  kite build
  kite build gruvbox
  kite serve
  kite list-themes
  kite init

DESCRIPTION:
  Kite converts your content into a static website using themes and templates.
`)
}