2019-01-01 19:41:03 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2020-10-11 13:35:13 +02:00
|
|
|
goutil "git.gutmet.org/goutil.git/misc"
|
2019-01-01 19:41:03 +01:00
|
|
|
"git.gutmet.org/simpleserver.git"
|
|
|
|
"git.gutmet.org/wombat.git/gallery"
|
|
|
|
"git.gutmet.org/wombat.git/generate"
|
|
|
|
"git.gutmet.org/wombat.git/initer"
|
2021-06-26 17:09:41 +02:00
|
|
|
"git.gutmet.org/wombat.git/page"
|
2019-01-01 19:41:03 +01:00
|
|
|
"git.gutmet.org/wombat.git/post"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
func serve(args []string) error {
|
|
|
|
simpleserver.Serve("stage2")
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-06-26 17:09:41 +02:00
|
|
|
func ifInited(cmd goutil.Command) goutil.Command {
|
|
|
|
oldExec := cmd.Exec
|
|
|
|
cmd.Exec = func(args []string) error {
|
|
|
|
initer.InitializedOrDie()
|
|
|
|
return oldExec(args)
|
|
|
|
}
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
2019-01-01 19:41:03 +01:00
|
|
|
func main() {
|
|
|
|
commands := []goutil.Command{
|
|
|
|
goutil.NewCommandWithFlags("init", initer.Command, "initialize wombat directory"),
|
2021-06-26 17:09:41 +02:00
|
|
|
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")),
|
2021-06-26 17:39:56 +02:00
|
|
|
ifInited(goutil.NewCommandWithFlags("newgallery", gallery.NewCommand, "init new picture gallery")),
|
|
|
|
ifInited(goutil.NewCommandWithFlags("genpics", gallery.Command, "generate picture galleries")),
|
2019-01-01 19:41:03 +01:00
|
|
|
}
|
|
|
|
err := goutil.Execute(commands)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintln(os.Stderr, err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|