1
0
Fork 0

refactor(main.go): use cobra for cli and move main.go to root dir

This commit is contained in:
Vojtěch Mareš 2024-04-28 15:14:08 +02:00
parent 9d2e456150
commit ac52934ee7
Signed by: vojtech.mares
GPG key ID: C6827B976F17240D
3 changed files with 33 additions and 15 deletions

24
cmd/root.go Normal file
View file

@ -0,0 +1,24 @@
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
var rootCmd = &cobra.Command{
Use: "backoffice",
Short: "Backoffice backend: server, migrations, etc. Everything in a single binary",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
// Do Stuff Here
},
}
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}

View file

@ -1,15 +0,0 @@
package main
import (
"log"
"time"
)
func main() {
log.Println("Starting backoffice-api server...")
log.Println("Simulating a running server...")
// do nothing, simulate a running server
for {
time.Sleep(1 * time.Second)
}
}

9
main.go Normal file
View file

@ -0,0 +1,9 @@
package main
import "gitlab.mareshq.com/hq/backoffice/backoffice-api/cmd"
//go:generate go run github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen --config=oapi-codegen.yaml ./api/v1/openapi.yaml
func main() {
cmd.Execute()
}