mirror of
https://github.com/facundoolano/jorge.git
synced 2024-12-27 21:58:50 +01:00
73bbaa2c50
Squashed commit of the following: commit 7c5b6bf95b14e402b68b141a7d60ccb1468f12b3 Author: facundoolano <facundo.olano@gmail.com> Date: Sun Feb 11 13:15:08 2024 -0300 restore other tests commit 5cf5c43856fc1a9e8f23dc74b81607ab7387f4c3 Author: facundoolano <facundo.olano@gmail.com> Date: Sat Feb 10 23:13:31 2024 -0300 restore a test commit acca0936a42b8b915c25f96c6b435887d7235c23 Author: facundoolano <facundo.olano@gmail.com> Date: Sat Feb 10 22:52:41 2024 -0300 fix a bunch of bugs commit 6f8074402338194ebebaaf929a1d85fdbf0d5e22 Author: facundoolano <facundo.olano@gmail.com> Date: Sat Feb 10 22:00:43 2024 -0300 implement methods commit 5cfeb1ea8600317d8849c6dca63a009237e033af Author: facundoolano <facundo.olano@gmail.com> Date: Sat Feb 10 20:16:10 2024 -0300 add template package and struct commit 7a7b79e006ff6629cbf9445927e84e9c1600667b Author: facundoolano <facundo.olano@gmail.com> Date: Sat Feb 10 20:08:43 2024 -0300 stub template interface
47 lines
863 B
Go
47 lines
863 B
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/facundoolano/blorg/commands"
|
|
)
|
|
|
|
func main() {
|
|
err := run(os.Args)
|
|
|
|
if err != nil {
|
|
fmt.Println("error:", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func run(args []string) error {
|
|
// TODO consider using cobra or something else to make cli more declarative
|
|
// and get a better ux out of the box
|
|
initCmd := flag.NewFlagSet("init", flag.ExitOnError)
|
|
newCmd := flag.NewFlagSet("new", flag.ExitOnError)
|
|
|
|
if len(os.Args) < 2 {
|
|
// TODO print usage
|
|
return errors.New("expected subcommand")
|
|
}
|
|
|
|
switch os.Args[1] {
|
|
case "init":
|
|
initCmd.Parse(os.Args[2:])
|
|
return commands.Init()
|
|
case "build":
|
|
return commands.Build()
|
|
case "new":
|
|
newCmd.Parse(os.Args[2:])
|
|
return commands.New()
|
|
case "serve":
|
|
return commands.Serve()
|
|
default:
|
|
// TODO print usage
|
|
return errors.New("unknown subcommand")
|
|
}
|
|
}
|