Move trySetup to setup.go

This commit is contained in:
Melon 2025-01-31 18:56:23 +00:00
parent c373f18336
commit 645d22b856
Signed by: melon
GPG Key ID: 6C9D970C50D26A25
2 changed files with 14 additions and 15 deletions

View File

@ -1,7 +1,6 @@
package main package main
import ( import (
"errors"
"flag" "flag"
"github.com/1f349/mjwt" "github.com/1f349/mjwt"
"github.com/1f349/orchid" "github.com/1f349/orchid"
@ -109,17 +108,3 @@ func getWD(configPath string) (string, error) {
} }
return filepath.Dir(wdAbs), nil return filepath.Dir(wdAbs), nil
} }
func trySetup(wd string) {
// handle potential errors during setup
err := runSetup(wd)
switch {
case errors.Is(err, errExitSetup):
// exit setup without questions
return
case err == nil:
return
default:
logger.Logger.Fatal("Failed to run setup", "err", err)
}
}

View File

@ -23,6 +23,20 @@ import (
var errExitSetup = errors.New("exit setup") var errExitSetup = errors.New("exit setup")
func trySetup(wd string) {
// handle potential errors during setup
err := runSetup(wd)
switch {
case errors.Is(err, errExitSetup):
// exit setup without questions
return
case err == nil:
return
default:
logger.Logger.Fatal("Failed to run setup", "err", err)
}
}
func runSetup(wd string) error { func runSetup(wd string) error {
// ask about running the setup steps // ask about running the setup steps
createFile := false createFile := false