2015-01-17 01:37:21 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2015-05-25 02:00:21 +00:00
|
|
|
"io/ioutil"
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"path"
|
|
|
|
|
|
|
|
"github.com/khlieng/name_pending/assets"
|
2015-05-01 20:59:46 +00:00
|
|
|
"github.com/khlieng/name_pending/commands"
|
2015-05-25 02:00:21 +00:00
|
|
|
"github.com/khlieng/name_pending/storage"
|
2015-01-17 01:37:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2015-05-25 02:00:21 +00:00
|
|
|
initConfig()
|
2015-05-01 20:59:46 +00:00
|
|
|
commands.Execute()
|
2015-01-17 01:37:21 +00:00
|
|
|
}
|
2015-05-25 02:00:21 +00:00
|
|
|
|
|
|
|
func initConfig() {
|
|
|
|
configPath := path.Join(storage.AppDir, "config.toml")
|
|
|
|
|
|
|
|
if _, err := os.Stat(configPath); os.IsNotExist(err) {
|
|
|
|
config, err := assets.Asset("config.default.toml")
|
|
|
|
if err != nil {
|
|
|
|
log.Println(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
err = ioutil.WriteFile(configPath, config, 0600)
|
|
|
|
if err != nil {
|
|
|
|
log.Println(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|