jorge/main.go
Facundo Olano b3594be86c
Refactor CLI using kong (#13)
* use kong for cli parsing

* fix kong usage

* remove conditional

* don't blow up serve if src dir is missing

* load config in main side (boilerplaty)

* fix weird names

* add versions and aliases

* fix version printing

* replace command switch with Run methods

* move subcommand structs to commands package

* distribute commands into files

* add usage to docs

* add flags to configure server
2024-02-24 12:39:45 -03:00

25 lines
724 B
Go

package main
import (
"github.com/alecthomas/kong"
"github.com/facundoolano/jorge/commands"
)
var cli struct {
Init commands.Init `cmd:"" help:"Initialize a new website project." aliases:"i"`
Build commands.Build `cmd:"" help:"Build a website project." aliases:"b"`
Post commands.Post `cmd:"" help:"Initialize a new post template file." help:"title of the new post." aliases:"p"`
Serve commands.Serve `cmd:"" help:"Run a local server for the website." aliases:"s"`
Version kong.VersionFlag `short:"v"`
}
func main() {
ctx := kong.Parse(
&cli,
kong.UsageOnError(),
kong.HelpOptions{FlagsLast: true},
kong.Vars{"version": "jorge v.0.1.2"},
)
err := ctx.Run()
ctx.FatalIfErrorf(err)
}