Skip to content

Commit

Permalink
Reimplement -datadir flag. Implements #79
Browse files Browse the repository at this point in the history
The config file is actually loaded from the folder that datadir points at
  • Loading branch information
Maran committed Jun 11, 2014
1 parent 57e3b1b commit e36badd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions ethereal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ var ImportKey string
var ExportKey bool
var AssetPath string

var Datadir string

func Init() {
flag.StringVar(&Identifier, "id", "", "Custom client identifier")
flag.StringVar(&OutboundPort, "port", "30303", "listening port")
Expand All @@ -35,5 +37,7 @@ func Init() {
flag.BoolVar(&ExportKey, "export", false, "export private key")
flag.StringVar(&ImportKey, "import", "", "imports the given private key (hex)")

flag.StringVar(&Datadir, "datadir", ".ethereal", "specifies the datadir to use. Takes precedence over config file.")

flag.Parse()
}
4 changes: 2 additions & 2 deletions ethereal/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ func main() {
ethchain.InitFees()

g, err := globalconf.NewWithOptions(&globalconf.Options{
Filename: path.Join(ethutil.ApplicationFolder(".ethereal"), "conf.ini"),
Filename: path.Join(ethutil.ApplicationFolder(Datadir), "conf.ini"),
})
if err != nil {
fmt.Println(err)
} else {
g.ParseAll()
}
ethutil.ReadConfig(".ethereal", ethutil.LogFile|ethutil.LogStd, g, Identifier)
ethutil.ReadConfig(Datadir, ethutil.LogFile|ethutil.LogStd, g, Identifier)

// Instantiated a eth stack
ethereum, err := eth.New(eth.CapDefault, UseUPnP)
Expand Down
4 changes: 4 additions & 0 deletions ethereum/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ var NonInteractive bool
var StartJsConsole bool
var InputFile string

var Datadir string

func Init() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "%s [options] [filename]:\n", os.Args[0])
Expand All @@ -46,6 +48,8 @@ func Init() {
flag.StringVar(&LogFile, "logfile", "", "log file (defaults to standard output)")
flag.StringVar(&ImportKey, "import", "", "imports the given private key (hex)")

flag.StringVar(&Datadir, "datadir", ".ethereum", "specifies the datadir to use. Takes precedence over config file.")

flag.Parse()

InputFile = flag.Arg(0)
Expand Down
4 changes: 2 additions & 2 deletions ethereum/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ func main() {
}

g, err := globalconf.NewWithOptions(&globalconf.Options{
Filename: path.Join(ethutil.ApplicationFolder(".ethereum"), "conf.ini"),
Filename: path.Join(ethutil.ApplicationFolder(Datadir), "conf.ini"),
})
if err != nil {
fmt.Println(err)
} else {
g.ParseAll()
}
ethutil.ReadConfig(".ethereum", lt, g, Identifier)
ethutil.ReadConfig(Datadir, lt, g, Identifier)

logger := ethutil.Config.Log

Expand Down

0 comments on commit e36badd

Please sign in to comment.