Skip to content
Snippets Groups Projects
Commit 197b9760 authored by Benjamin Bollen's avatar Benjamin Bollen
Browse files

continue work on cobra; add serve command; do struct and some default flags

parent 607eae04
No related branches found
No related tags found
No related merge requests found
......@@ -24,11 +24,15 @@ import (
common "github.com/eris-ltd/common/go/common"
version "github.com/eris-ltd/eris-db/version"
defintion "github.com/eris-ltd/eris-db/defintions"
version "github.com/eris-ltd/eris-db/version"
)
const VERSION = version.VERSION
// Global Do struct
var do *definitions.Do
var ErisDbCmd = &cobra.Command {
Use: "eris-db"
Short: "Eris-DB is the beating heart of the eris chain."
......@@ -47,17 +51,48 @@ Complete documentation is available at https://docs.erisindustries.com
}
func Execute() {
InitErisDb()
AddGlobalFlags()
AddCommands()
ErisDbCmd.Execute()
}
func InitErisDb() {
// initialise an empty do struct for command execution
do = definitions.NowDo()
}
func AddCommands() {
buildServeCommand()
ErisDbCmd.AddCommand()
}
func AddGlobalFlags() {
ErisCMCmd.PersistentFlags().BoolVarP(&do.Verbose, "verbose", "v", defaultVerbose(), "verbose output; more output than no output flags; less output than debug level; default respects $ERIS_DB_VERBOSE")
ErisCMCmd.PersistentFlags().BoolVarP(&do.Debug, "debug", "d", defaultDebug(), "debug level output; the most output available for eris-db; if it is too chatty use verbose flag; default respects $ERIS_DB_DEBUG")
ErisCMCmd.PersistentFlags().BoolVarP(&do.Output, "output", "o", defaultOutput(), "should eris-db provide an output of its job; default respects $ERIS_DB_OUTPUT")
ErisDbCmd.PersistentFlags().BoolVarP(&do.Verbose, "verbose", "v", defaultVerbose(), "verbose output; more output than no output flags; less output than debug level; default respects $ERIS_DB_VERBOSE")
ErisDbCmd.PersistentFlags().BoolVarP(&do.Debug, "debug", "d", defaultDebug(), "debug level output; the most output available for eris-db; if it is too chatty use verbose flag; default respects $ERIS_DB_DEBUG")
ErisDbCmd.PersistentFlags().BoolVarP(&do.Output, "output", "o", defaultOutput(), "should eris-db provide an output of its execution; default respects $ERIS_DB_OUTPUT")
}
//------------------------------------------------------------------------------
// Defaults
func defaultVerbose() bool {
return setDefaultBool("ERIS_DB_VERBOSE", false)
}
func defaultDebug() bool {
return setDefaultBool("ERIS_DB_DEBUG", false)
}
func defaultOutput() bool {
return setDefaultBool("ERIS_DB_OUTPUT", true)
}
func setDefaultBool(envVar string, def bool) bool {
env := os.Getenv(envVar)
if env != "" {
i, _ := strconv.ParseBool(env)
return i
}
return def
}
File moved
......@@ -27,4 +27,24 @@ import (
serve "github.com/eris-ltd/eris-db/serve"
)
var
var ServeCmd = &cobra.Command {
Use: "serve",
Short: "Eris-DB serve starts an eris-db node with client API enabled by default.",
Long: `Eris-DB serve starts an eris-db node with client API enabled by default.
The Eris-DB node is modularly configured for the consensus engine and application
manager. The client API can be disabled.`,
Example: `$ eris-db serve -- will start the Eris-DB node based on the configuration file in the current working directory,
$ eris-db serve myChainId --work-dir=/path/to/config -- will start the Eris-DB node based on the configuration file provided and assert the chain id matches.`,
PreRun: func(cmd *cobra.Command, args []string) {
// TODO: [ben] log marmotty welcome
}
}
//------------------------------------------------------------------------------
// functions
func Serve(cmd *cobra.Command, args []string) {
}
// Copyright 2015, 2016 Eris Industries (UK) Ltd.
// This file is part of Eris-RT
// Eris-RT is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Eris-RT is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Eris-RT. If not, see <http://www.gnu.org/licenses/>.
package definitions
type Do struct {
Debug bool
Verbose bool
ChainId string
// ChainType string
// CSV string
// AccountTypes []string
// Zip bool
// Tarball bool
Output bool
// Accounts []*Account
// Result string
}
func NowDo() *Do {
return &Do{}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment