-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
38 lines (33 loc) · 810 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"github.com/cosmos/cosmos-sdk/server"
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
"github.com/gjermundgaraba/nft-cli/cmd"
"github.com/joho/godotenv"
"log"
"os"
"path/filepath"
)
func main() {
// TODO: Is this really needed?
// check if .env file exists, if so, load it
if _, err := os.Stat(".env"); err == nil || !os.IsNotExist(err) {
if err := godotenv.Load(); err != nil {
log.Fatalf("Error loading .env file, %v", err)
}
}
userHomeDir, err := os.UserHomeDir()
if err != nil {
panic(err)
}
appHomeDir := filepath.Join(userHomeDir, ".gon-cli")
rootCmd := cmd.NewRootCmd(appHomeDir)
if err := svrcmd.Execute(rootCmd, "", appHomeDir); err != nil {
switch e := err.(type) {
case server.ErrorCode:
os.Exit(e.Code)
default:
os.Exit(1)
}
}
}