main.go (view raw)
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 ( "fmt" "os" "git.icyphox.sh/vite/commands" ) func main() { args := os.Args helpStr := `usage: vite [options] A simple and minimal static site generator. options: init PATH create vite project at PATH build builds the current project new PATH create a new markdown post ` if len(args) <= 1 { fmt.Println(helpStr) return } switch args[1] { case "init": if len(args) <= 2 { fmt.Println(helpStr) return } initPath := args[2] err := commands.Init(initPath) if err != nil { fmt.Fprintf(os.Stderr, "error: init: %+v\n", err) } case "build": err := commands.Build() if err != nil { fmt.Fprintf(os.Stderr, "error: build: %+v\n", err) } case "new": if len(args) <= 2 { fmt.Println(helpStr) return } newPath := args[2] err := commands.New(newPath) if err != nil { fmt.Fprintf(os.Stderr, "error: new: %+v\n", err) } } } |