all repos — vite @ 9221f0d1c90e7944aeaa7201bd54be04bb475542

a fast (this time, actually) and minimal static site generator

main.go (view raw)

 1package main
 2
 3import (
 4	"fmt"
 5	"os"
 6
 7	"git.icyphox.sh/vite/commands"
 8)
 9
10func main() {
11	args := os.Args
12
13	helpStr := `usage: vite [options]
14
15A simple and minimal static site generator.
16
17options:
18    init PATH       create vite project at PATH
19    build           builds the current project
20    new PATH        create a new markdown post
21        `
22
23	if len(args) <= 1 {
24		fmt.Println(helpStr)
25		return
26	}
27
28	switch args[1] {
29	case "init":
30		if len(args) <= 2 {
31			fmt.Println(helpStr)
32			return
33		}
34		initPath := args[2]
35		err := commands.Init(initPath)
36		if err != nil {
37			fmt.Fprintf(os.Stderr, "error: init: %+v\n", err)
38		}
39
40	case "build":
41		err := commands.Build()
42		if err != nil {
43			fmt.Fprintf(os.Stderr, "error: build: %+v\n", err)
44		}
45
46	case "new":
47		if len(args) <= 2 {
48			fmt.Println(helpStr)
49			return
50		}
51		newPath := args[2]
52		err := commands.New(newPath)
53		if err != nil {
54			fmt.Fprintf(os.Stderr, "error: new: %+v\n", err)
55		}
56	}
57
58}