package main import ( "fmt" "os" goutil "git.fireandbrimst.one/aw/goutil/misc" "git.fireandbrimst.one/aw/simpleserver" "git.fireandbrimst.one/aw/wombat/gallery" "git.fireandbrimst.one/aw/wombat/generate" "git.fireandbrimst.one/aw/wombat/initer" "git.fireandbrimst.one/aw/wombat/page" "git.fireandbrimst.one/aw/wombat/post" ) func serve(args []string) error { simpleserver.Serve("stage2") return nil } func ifInited(cmd goutil.Command) goutil.Command { oldExec := cmd.Exec cmd.Exec = func(args []string) error { initer.InitializedOrDie() return oldExec(args) } return cmd } func main() { commands := []goutil.Command{ goutil.NewCommandWithFlags("init", initer.Command, "initialize wombat directory"), ifInited(goutil.NewCommandWithFlags("gen", generate.Command, "generate the website")), ifInited(goutil.NewCommand("serve", serve, "just execute web server")), ifInited(goutil.NewCommandWithFlags("newpost", post.Command, "create a new blogpost")), ifInited(goutil.NewCommandWithFlags("newpage", page.Command, "create a new page")), ifInited(goutil.NewCommandWithFlags("newgallery", gallery.NewCommand, "init new picture gallery")), ifInited(goutil.NewCommandWithFlags("genpics", gallery.Command, "generate picture galleries")), } err := goutil.Execute(commands) if err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } }