aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/utils
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-09-16 17:53:50 +0800
committerFelix Lange <fjl@twurst.com>2016-09-16 21:24:31 +0800
commitb42a5b118f1aa7ac1235547c8594146978941401 (patch)
tree5a0a56308fe3137f1c9c69394281dadfc4551f37 /cmd/utils
parenteeb322ae649c4a1a32430cdddfffed70f509181e (diff)
downloadgo-tangerine-b42a5b118f1aa7ac1235547c8594146978941401.tar.gz
go-tangerine-b42a5b118f1aa7ac1235547c8594146978941401.tar.zst
go-tangerine-b42a5b118f1aa7ac1235547c8594146978941401.zip
common, node: move datadir defaults into package node
Diffstat (limited to 'cmd/utils')
-rw-r--r--cmd/utils/customflags.go14
-rw-r--r--cmd/utils/flags.go16
2 files changed, 20 insertions, 10 deletions
diff --git a/cmd/utils/customflags.go b/cmd/utils/customflags.go
index 5cbccfe98..11c92d451 100644
--- a/cmd/utils/customflags.go
+++ b/cmd/utils/customflags.go
@@ -137,9 +137,19 @@ func (self *DirectoryFlag) Set(value string) {
// Note, it has limitations, e.g. ~someuser/tmp will not be expanded
func expandPath(p string) string {
if strings.HasPrefix(p, "~/") || strings.HasPrefix(p, "~\\") {
- if user, err := user.Current(); err == nil {
- p = user.HomeDir + p[1:]
+ if home := homeDir(); home != "" {
+ p = home + p[1:]
}
}
return path.Clean(os.ExpandEnv(p))
}
+
+func homeDir() string {
+ if home := os.Getenv("HOME"); home != "" {
+ return home
+ }
+ if usr, err := user.Current(); err == nil {
+ return usr.HomeDir
+ }
+ return ""
+}
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 47a8ebd41..0be499c5b 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -105,7 +105,7 @@ var (
DataDirFlag = DirectoryFlag{
Name: "datadir",
Usage: "Data directory for the databases and keystore",
- Value: DirectoryString{common.DefaultDataDir()},
+ Value: DirectoryString{node.DefaultDataDir()},
}
KeyStoreDirFlag = DirectoryFlag{
Name: "keystore",
@@ -139,7 +139,7 @@ var (
DocRootFlag = DirectoryFlag{
Name: "docroot",
Usage: "Document Root for HTTPClient file scheme",
- Value: DirectoryString{common.HomeDir()},
+ Value: DirectoryString{homeDir()},
}
CacheFlag = cli.IntFlag{
Name: "cache",
@@ -245,12 +245,12 @@ var (
RPCListenAddrFlag = cli.StringFlag{
Name: "rpcaddr",
Usage: "HTTP-RPC server listening interface",
- Value: common.DefaultHTTPHost,
+ Value: node.DefaultHTTPHost,
}
RPCPortFlag = cli.IntFlag{
Name: "rpcport",
Usage: "HTTP-RPC server listening port",
- Value: common.DefaultHTTPPort,
+ Value: node.DefaultHTTPPort,
}
RPCCORSDomainFlag = cli.StringFlag{
Name: "rpccorsdomain",
@@ -268,13 +268,13 @@ var (
}
IPCApiFlag = cli.StringFlag{
Name: "ipcapi",
- Usage: "API's offered over the IPC-RPC interface",
+ Usage: "APIs offered over the IPC-RPC interface",
Value: rpc.DefaultIPCApis,
}
IPCPathFlag = DirectoryFlag{
Name: "ipcpath",
Usage: "Filename for IPC socket/pipe within the datadir (explicit paths escape it)",
- Value: DirectoryString{common.DefaultIPCSocket},
+ Value: DirectoryString{"geth.ipc"},
}
WSEnabledFlag = cli.BoolFlag{
Name: "ws",
@@ -283,12 +283,12 @@ var (
WSListenAddrFlag = cli.StringFlag{
Name: "wsaddr",
Usage: "WS-RPC server listening interface",
- Value: common.DefaultWSHost,
+ Value: node.DefaultWSHost,
}
WSPortFlag = cli.IntFlag{
Name: "wsport",
Usage: "WS-RPC server listening port",
- Value: common.DefaultWSPort,
+ Value: node.DefaultWSPort,
}
WSApiFlag = cli.StringFlag{
Name: "wsapi",