status-go/cmd/statusd/flags.go
Pedro Pombeiro 3d00af7fa3
Streamline configuration in status-go. Part of #1180 (#1183)
- Replace command line flags with `-c` config flag. Part of #1180
- Convert node config private keys to hex-encoded string versions.
- Remove `GenerateConfig` from library.
- Remove unused `FirebaseConfig` from library.
- Fix loading of `config/status-chain-genesis.json` in non-dev machines.
2018-09-13 18:31:29 +02:00

38 lines
673 B
Go

package main
import (
"fmt"
"os"
"path"
"strings"
)
// configFlags represents an array of JSON configuration files passed to a command line utility
type configFlags []string
func (f *configFlags) String() string {
return strings.Join(*f, ", ")
}
func (f *configFlags) Set(value string) error {
if !path.IsAbs(value) {
// Convert to absolute path
cwd, err := os.Getwd()
if err != nil {
return err
}
value = path.Join(cwd, value)
}
// Check that the file exists
stat, err := os.Stat(value)
if err != nil {
return err
}
if stat.IsDir() {
return fmt.Errorf("path does not represent a file: %s", value)
}
*f = append(*f, value)
return nil
}