Fix conf dir creation

This commit is contained in:
Brian Buller 2020-10-19 08:03:42 -05:00
parent 5f07ea41d2
commit 215e7ebd32

View File

@ -62,13 +62,14 @@ func (a *AppState) initialize() error {
flag.Parse()
a.Parms = flag.Args()
if err := a.validateConfDir(); err != nil {
return err
}
a.QuestsDir = a.ConfDir + "/quests"
a.ShipsDir = a.ConfDir + "/ships"
a.HoldsDir = a.ConfDir + "/holds"
if err := a.validateConfDir(); err != nil {
return err
}
// Figure out what 'mode' we're running in
if *validateQuest != "" {
a.Mode = MODE_VALIDATE_QUEST
@ -129,15 +130,19 @@ func (a *AppState) validateConfDir() error {
ans := cli.PromptWDefault(fmt.Sprintf("Create configuration directories (%s)? [n]", a.ConfDir), "n")
if strings.ToLower(ans) == "y" {
if err := os.Mkdir(a.ConfDir, 0700); err != nil {
cli.PrintErr("Error creating main configuration directory")
return err
}
if err := os.Mkdir(a.QuestsDir, 0700); err != nil {
cli.PrintErr(fmt.Sprintf("Error creating Quests directory (%s)", a.QuestsDir))
return err
}
if err := os.Mkdir(a.ShipsDir, 0700); err != nil {
cli.PrintErr(fmt.Sprintf("Error creating Ships directory (%s)", a.ShipsDir))
return err
}
if err := os.Mkdir(a.HoldsDir, 0700); err != nil {
cli.PrintErr(fmt.Sprintf("Error creating Holds directory (%s)", a.HoldsDir))
return err
}
} else {