mirror of
https://github.com/1f349/orchid.git
synced 2025-02-05 14:06:40 +00:00
Move trySetup to setup.go
This commit is contained in:
parent
c373f18336
commit
645d22b856
@ -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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user