aboutsummaryrefslogtreecommitdiffstats
path: root/ethutil
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-03-06 21:02:16 +0800
committerFelix Lange <fjl@twurst.com>2015-03-06 21:02:16 +0800
commite64f727529287b7414af6d1f482ea5f318cbd2eb (patch)
treef1939dffc5973597e6da17ef60ad2044af7f4340 /ethutil
parenta91bf014295bfaebee976f9e0e994e8a83e8e356 (diff)
parentde86403f330e68df8fc4aee00df98374b7842d0d (diff)
downloadgo-tangerine-e64f727529287b7414af6d1f482ea5f318cbd2eb.tar
go-tangerine-e64f727529287b7414af6d1f482ea5f318cbd2eb.tar.gz
go-tangerine-e64f727529287b7414af6d1f482ea5f318cbd2eb.tar.bz2
go-tangerine-e64f727529287b7414af6d1f482ea5f318cbd2eb.tar.lz
go-tangerine-e64f727529287b7414af6d1f482ea5f318cbd2eb.tar.xz
go-tangerine-e64f727529287b7414af6d1f482ea5f318cbd2eb.tar.zst
go-tangerine-e64f727529287b7414af6d1f482ea5f318cbd2eb.zip
Merge pull request #433 from fjl/newcli
Improved CLI
Diffstat (limited to 'ethutil')
-rw-r--r--ethutil/config.go35
1 files changed, 16 insertions, 19 deletions
diff --git a/ethutil/config.go b/ethutil/config.go
index fc8fb4e3f..c45c310ce 100644
--- a/ethutil/config.go
+++ b/ethutil/config.go
@@ -20,30 +20,27 @@ type ConfigManager struct {
conf *globalconf.GlobalConf
}
-var Config *ConfigManager
-
// Read config
//
// Initialize Config from Config File
func ReadConfig(ConfigFile string, Datadir string, EnvPrefix string) *ConfigManager {
- if Config == nil {
- // create ConfigFile if does not exist, otherwise globalconf panic when trying to persist flags
- if !FileExist(ConfigFile) {
- fmt.Printf("config file '%s' doesn't exist, creating it\n", ConfigFile)
- os.Create(ConfigFile)
- }
- g, err := globalconf.NewWithOptions(&globalconf.Options{
- Filename: ConfigFile,
- EnvPrefix: EnvPrefix,
- })
- if err != nil {
- fmt.Println(err)
- } else {
- g.ParseAll()
- }
- Config = &ConfigManager{ExecPath: Datadir, Debug: true, conf: g, Paranoia: true}
+ if !FileExist(ConfigFile) {
+ // create ConfigFile if it does not exist, otherwise
+ // globalconf will panic when trying to persist flags.
+ fmt.Printf("config file '%s' doesn't exist, creating it\n", ConfigFile)
+ os.Create(ConfigFile)
+ }
+ g, err := globalconf.NewWithOptions(&globalconf.Options{
+ Filename: ConfigFile,
+ EnvPrefix: EnvPrefix,
+ })
+ if err != nil {
+ fmt.Println(err)
+ } else {
+ g.ParseAll()
}
- return Config
+ cfg := &ConfigManager{ExecPath: Datadir, Debug: true, conf: g, Paranoia: true}
+ return cfg
}
// provides persistence for flags