diff --git a/.gitignore b/.gitignore index aecc667..2c036d5 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,6 @@ __debug_bin *.tar.gz transpile -mothd winmoth.*.zip -*.exe +/mothd +/*.exe diff --git a/cmd/mothd/main.go b/cmd/mothd/main.go index 32a1cc4..8487efe 100644 --- a/cmd/mothd/main.go +++ b/cmd/mothd/main.go @@ -6,6 +6,7 @@ import ( "log" "mime" "os" + "path/filepath" "time" "github.com/spf13/afero" @@ -54,21 +55,38 @@ func main() { ) flag.Parse() + var theme *Theme osfs := afero.NewOsFs() - theme := NewTheme(afero.NewBasePathFs(osfs, *themePath)) + if p, err := filepath.Abs(*themePath); err != nil { + log.Fatal(err) + } else { + theme = NewTheme(afero.NewBasePathFs(osfs, p)) + } config := Configuration{} var provider PuzzleProvider - provider = NewMothballs(afero.NewBasePathFs(osfs, *mothballPath)) + if p, err := filepath.Abs(*mothballPath); err != nil { + log.Fatal(err) + } else { + provider = NewMothballs(afero.NewBasePathFs(osfs, p)) + } if *puzzlePath != "" { - provider = NewTranspilerProvider(afero.NewBasePathFs(osfs, *puzzlePath)) + if p, err := filepath.Abs(*puzzlePath); err != nil { + log.Fatal(err) + } else { + provider = NewTranspilerProvider(afero.NewBasePathFs(osfs, p)) + } config.Devel = true log.Println("-=- You are in development mode, champ! -=-") } var state StateProvider - state = NewState(afero.NewBasePathFs(osfs, *statePath)) + if p, err := filepath.Abs(*statePath); err != nil { + log.Fatal(err) + } else { + state = NewState(afero.NewBasePathFs(osfs, p)) + } if config.Devel { state = NewDevelState(state) }