1
0
mirror of https://github.com/zu1k/nali.git synced 2025-01-23 05:39:03 +08:00
nali/main.go

33 lines
578 B
Go
Raw Normal View History

2020-07-17 09:41:09 +08:00
package main
2020-07-17 09:05:25 +08:00
2020-07-17 09:41:09 +08:00
import (
"log"
"os"
"path/filepath"
2020-07-17 09:05:25 +08:00
2020-07-17 09:41:09 +08:00
"github.com/zu1k/nali/cmd"
"github.com/zu1k/nali/constant"
)
2020-07-17 09:05:25 +08:00
func main() {
2020-07-17 09:41:09 +08:00
setHomePath()
2020-07-17 09:05:25 +08:00
cmd.Execute()
}
2020-07-17 09:41:09 +08:00
func setHomePath() {
2020-07-22 06:32:13 +08:00
homePath := os.Getenv("NALI_DB_HOME")
if homePath == "" {
homeDir, err := os.UserHomeDir()
if err != nil {
panic(err)
}
homePath = filepath.Join(homeDir, ".nali")
2020-07-17 09:41:09 +08:00
}
constant.HomePath = homePath
if _, err := os.Stat(homePath); os.IsNotExist(err) {
if err := os.MkdirAll(homePath, 0777); err != nil {
log.Fatal("can not create", homePath, ", use bin dir instead")
}
}
}