Rough separation of gaiad and gaiacli
This commit is contained in:
parent
959ad1431e
commit
b10afcaf4c
5
Makefile
5
Makefile
|
@ -12,8 +12,9 @@ ci: get_tools get_vendor_deps build test_cover
|
|||
### Build
|
||||
|
||||
# This can be unified later, here for easy demos
|
||||
chub:
|
||||
go install $(BUILD_FLAGS) ./examples/chub
|
||||
gaia:
|
||||
go build $(BUILD_FLAGS) -o build/gaid ./examples/gaiad
|
||||
go build $(BUILD_FLAGS) -o build/gaiacli ./examples/gaiacli
|
||||
|
||||
build:
|
||||
@rm -rf examples/basecoin/vendor/
|
||||
|
|
|
@ -7,8 +7,6 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/tendermint/tmlibs/cli"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -53,15 +51,11 @@ func main() {
|
|||
// disable sorting
|
||||
cobra.EnableCommandSorting = false
|
||||
|
||||
// TODO: set this to something real
|
||||
var node baseapp.BaseApp
|
||||
|
||||
// add commands
|
||||
AddGetCommand(getAccountCmd)
|
||||
AddPostCommand(postSendCommand())
|
||||
|
||||
chubCmd.AddCommand(
|
||||
NodeCommands(node),
|
||||
KeyCommands(),
|
||||
ClientCommands(),
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/tendermint/tmlibs/cli"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
)
|
||||
|
||||
const (
|
||||
flagTo = "to"
|
||||
flagAmount = "amount"
|
||||
flagFee = "fee"
|
||||
)
|
||||
|
||||
// gaiadCmd is the entry point for this binary
|
||||
var (
|
||||
gaiadCmd = &cobra.Command{
|
||||
Use: "gaiad",
|
||||
Short: "Gaia Daemon (server)",
|
||||
}
|
||||
)
|
||||
|
||||
func todoNotImplemented(_ *cobra.Command, _ []string) error {
|
||||
return errors.New("TODO: Command not yet implemented")
|
||||
}
|
||||
|
||||
func main() {
|
||||
// TODO: set this to something real
|
||||
var node baseapp.BaseApp
|
||||
|
||||
AddNodeCommands(gaiadCmd, node)
|
||||
gaiadCmd.AddCommand(
|
||||
VersionCmd,
|
||||
)
|
||||
|
||||
// prepare and add flags
|
||||
executor := cli.PrepareBaseCmd(gaiadCmd, "GA", os.ExpandEnv("$HOME/.gaiad"))
|
||||
executor.Execute()
|
||||
}
|
|
@ -24,21 +24,16 @@ var (
|
|||
}
|
||||
)
|
||||
|
||||
// NodeCommands registers a sub-tree of commands to interact with
|
||||
// a local full-node.
|
||||
// AddNodeCommands registers all commands to interact
|
||||
// with a local full-node as subcommands of the argument.
|
||||
//
|
||||
// Accept an application it should start
|
||||
func NodeCommands(node baseapp.BaseApp) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "node",
|
||||
Short: "Run the full node",
|
||||
}
|
||||
func AddNodeCommands(cmd *cobra.Command, node baseapp.BaseApp) {
|
||||
cmd.AddCommand(
|
||||
initNodeCmd,
|
||||
startNodeCmd(node),
|
||||
resetNodeCmd,
|
||||
)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func startNodeCmd(node baseapp.BaseApp) *cobra.Command {
|
|
@ -0,0 +1,26 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
)
|
||||
|
||||
var (
|
||||
// VersionCmd prints out the current sdk version
|
||||
VersionCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Print the app version",
|
||||
Run: doVersionCmd,
|
||||
}
|
||||
)
|
||||
|
||||
func doVersionCmd(cmd *cobra.Command, args []string) {
|
||||
v := version.Version
|
||||
if version.GitCommit != "" {
|
||||
v = v + " " + version.GitCommit
|
||||
}
|
||||
fmt.Println(v)
|
||||
}
|
Loading…
Reference in New Issue