Skip to content

Commit

Permalink
propagate error on configure
Browse files Browse the repository at this point in the history
  • Loading branch information
ubaldus committed Jan 30, 2024
1 parent 7aae832 commit 882e85d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
4 changes: 3 additions & 1 deletion cmd/tibula/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import (
)

func main() {
sys.Configure()
if err := sys.Configure(); err != nil {
log.Fatal(err)
}
if sys.Commands.Start {
if sys.Options.DbName == "" && sys.Options.ConfigFile == "" {
if err := sys.ConfigRead("tibula.json", &sys.Options); err != nil {
Expand Down
16 changes: 5 additions & 11 deletions sys/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ package sys

import (
"flag"
"fmt"
"log"
"os"
)

func Configure() {
func Configure() error {
flag.BoolVar(&Commands.Start, "start", false, "start the web service")
flag.BoolVar(&Commands.DbSetup, "db-setup", false, "initialize the database")
flag.BoolVar(&Commands.Wizard, "wizard", false, "guided setup")
Expand All @@ -36,27 +33,24 @@ func Configure() {

if Options.ConfigFile != "" {
if err := ConfigRead(Options.ConfigFile, &Options); err != nil {
log.Fatalf("Cannot open config file: %v\n", err)
return err
}
}

if Commands.DbSetup {
if err := Setup(); err != nil {
log.Fatal(err)
return err
}
os.Exit(0)
}

if Commands.Wizard {
if err := wizardSetup(); err != nil {
fmt.Println(err)
os.Exit(1)
return err
}
os.Exit(0)
}

if Commands.Help {
Help()
os.Exit(0)
}
return nil
}

0 comments on commit 882e85d

Please sign in to comment.