/
nishimura_base.go
58 lines (46 loc) · 1.25 KB
/
nishimura_base.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package cmd
import (
"log"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var (
Nishimura = &cobra.Command{
Use: "Nishimura",
Short: "Nishimura is a FANUC Karel package configurator",
Long: `
Nishimura Karel package manager
===============================
Nishimura is a Karel package manager. The idea is that a Karel program
can put in an all containing package. This makes it more flexible to write
Karel Code and share the code with other users.
AUTHOR:
Anton Feldmann <anton.feldmann@gmail.com>
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\`,
}
confFile string
)
func init() {
cobra.OnInitialize(initConfig)
Nishimura.PersistentFlags().StringVar(&confFile, "config", DefaultConfPath(), "the config file to set the Path.")
Nishimura.AddCommand(version)
Nishimura.AddCommand(build)
Nishimura.AddCommand(compile)
}
func Execute() {
if err := Nishimura.Execute(); err != nil {
log.Fatal(err)
}
}
func initConfig() {
ncft.initNishimura(confFile)
ncft.build_file()
if confFile != "" {
// Use config file from the flag.
viper.SetConfigFile(confFile)
} else {
viper.AddConfigPath(ncft.RootDir)
viper.SetConfigName(ncft.ConfFile)
}
viper.AutomaticEnv() // read in environment variables that match
}