From 1024766514eea7bb628ec6e5ed974e997b8faefc Mon Sep 17 00:00:00 2001 From: zelig Date: Mon, 23 Jun 2014 12:20:59 +0100 Subject: refactor cli and gui wrapper code. Details: - all cli functions shared between ethereum and ethereal abstracted to utils/ cmd.go (should be ethcommon or shared or sth) - simplify main() now readable stepwise - rename main wrapper files to main.go - rename commmand line args definition file from config.go to flags.go - rename Do -> Start to parallel option names - register interrupt for rpc server stop - fix interrupt stopping js repl and ethereum - register interrupt for mining stop - custom config file option from command line - debug option from command line - loglevel option from command line - changed ethutil.Config API - default datadir and default config file set together with other flag defaults in wrappers - default assetpath set together with other command line flags defaults in gui wrapper (not in ethutil.Config or ui/ui_lib) - options precedence: default < config file < environment variables < command line --- ethereum/cmd.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 ethereum/cmd.go (limited to 'ethereum/cmd.go') diff --git a/ethereum/cmd.go b/ethereum/cmd.go new file mode 100644 index 000000000..0e9c2be8c --- /dev/null +++ b/ethereum/cmd.go @@ -0,0 +1,33 @@ +package main + +import ( + "github.com/ethereum/eth-go" + "github.com/ethereum/go-ethereum/utils" + "os" + "io/ioutil" +) + +func InitJsConsole(ethereum *eth.Ethereum) { + repl := NewJSRepl(ethereum) + go repl.Start() + utils.RegisterInterrupt(func(os.Signal) { + repl.Stop() + ethereum.Stop() + }) +} + +func ExecJsFile (ethereum *eth.Ethereum, InputFile string) { + file, err := os.Open(InputFile) + if err != nil { + logger.Fatalln(err) + } + content, err := ioutil.ReadAll(file) + if err != nil { + logger.Fatalln(err) + } + re := NewJSRE(ethereum) + utils.RegisterInterrupt(func(os.Signal) { + re.Stop() + }) + re.Run(string(content)) +} -- cgit v1.2.3 From 2f96652bb408e65c205317403d749ba9a395c6bb Mon Sep 17 00:00:00 2001 From: zelig Date: Thu, 26 Jun 2014 10:47:45 +0100 Subject: interrupt handlers now ordered --- ethereum/cmd.go | 1 - 1 file changed, 1 deletion(-) (limited to 'ethereum/cmd.go') diff --git a/ethereum/cmd.go b/ethereum/cmd.go index 0e9c2be8c..2dfd54666 100644 --- a/ethereum/cmd.go +++ b/ethereum/cmd.go @@ -12,7 +12,6 @@ func InitJsConsole(ethereum *eth.Ethereum) { go repl.Start() utils.RegisterInterrupt(func(os.Signal) { repl.Stop() - ethereum.Stop() }) } -- cgit v1.2.3 From ae5ace16190d48bfe7a0364fdb0b51644518ec42 Mon Sep 17 00:00:00 2001 From: zelig Date: Thu, 26 Jun 2014 18:41:36 +0100 Subject: go fmt --- ethereum/cmd.go | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'ethereum/cmd.go') diff --git a/ethereum/cmd.go b/ethereum/cmd.go index 2dfd54666..08147824d 100644 --- a/ethereum/cmd.go +++ b/ethereum/cmd.go @@ -1,32 +1,32 @@ package main import ( - "github.com/ethereum/eth-go" - "github.com/ethereum/go-ethereum/utils" - "os" - "io/ioutil" + "github.com/ethereum/eth-go" + "github.com/ethereum/go-ethereum/utils" + "io/ioutil" + "os" ) func InitJsConsole(ethereum *eth.Ethereum) { - repl := NewJSRepl(ethereum) - go repl.Start() - utils.RegisterInterrupt(func(os.Signal) { - repl.Stop() - }) + repl := NewJSRepl(ethereum) + go repl.Start() + utils.RegisterInterrupt(func(os.Signal) { + repl.Stop() + }) } -func ExecJsFile (ethereum *eth.Ethereum, InputFile string) { - file, err := os.Open(InputFile) - if err != nil { - logger.Fatalln(err) - } - content, err := ioutil.ReadAll(file) - if err != nil { - logger.Fatalln(err) - } - re := NewJSRE(ethereum) - utils.RegisterInterrupt(func(os.Signal) { - re.Stop() - }) - re.Run(string(content)) +func ExecJsFile(ethereum *eth.Ethereum, InputFile string) { + file, err := os.Open(InputFile) + if err != nil { + logger.Fatalln(err) + } + content, err := ioutil.ReadAll(file) + if err != nil { + logger.Fatalln(err) + } + re := NewJSRE(ethereum) + utils.RegisterInterrupt(func(os.Signal) { + re.Stop() + }) + re.Run(string(content)) } -- cgit v1.2.3