Start with demo chub command
Add version and node subcommand as TODOs
This commit is contained in:
parent
809102c952
commit
90a102cf3e
4
Makefile
4
Makefile
|
@ -11,6 +11,10 @@ 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
|
||||
|
||||
build:
|
||||
@rm -rf examples/basecoin/vendor/
|
||||
go build $(BUILD_FLAGS) -o build/basecoin ./examples/basecoin/cmd/...
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/tendermint/tmlibs/cli"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/app"
|
||||
)
|
||||
|
||||
// chubCmd is the entry point for this binary
|
||||
var (
|
||||
chubCmd = &cobra.Command{
|
||||
Use: "chub",
|
||||
Short: "Cosmos Hub command-line tool",
|
||||
Run: help,
|
||||
}
|
||||
|
||||
lineBreak = &cobra.Command{Run: func(*cobra.Command, []string) {}}
|
||||
)
|
||||
|
||||
func todoNotImplemented(_ *cobra.Command, _ []string) error {
|
||||
return errors.New("TODO: Command not yet implemented")
|
||||
}
|
||||
|
||||
func help(cmd *cobra.Command, args []string) {
|
||||
cmd.Help()
|
||||
}
|
||||
|
||||
func main() {
|
||||
// disable sorting
|
||||
cobra.EnableCommandSorting = false
|
||||
|
||||
// TODO: set this to something real
|
||||
var node app.App
|
||||
|
||||
// add commands
|
||||
// prepareRestServerCommands()
|
||||
// prepareClientCommands()
|
||||
|
||||
chubCmd.AddCommand(
|
||||
nodeCommand(node),
|
||||
// restServerCmd,
|
||||
// clientCmd,
|
||||
|
||||
lineBreak,
|
||||
versionCmd,
|
||||
)
|
||||
|
||||
// prepare and add flags
|
||||
// executor := cli.PrepareMainCmd(chubCmd, "CH", os.ExpandEnv("$HOME/.cosmos-chub"))
|
||||
executor := cli.PrepareBaseCmd(chubCmd, "CH", os.ExpandEnv("$HOME/.cosmos-chub"))
|
||||
executor.Execute()
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/app"
|
||||
)
|
||||
|
||||
var (
|
||||
initNodeCmd = &cobra.Command{
|
||||
Use: "init",
|
||||
Short: "Initialize full node",
|
||||
RunE: todoNotImplemented,
|
||||
}
|
||||
|
||||
resetNodeCmd = &cobra.Command{
|
||||
Use: "unsafe_reset_all",
|
||||
Short: "Reset full node data (danger, must resync)",
|
||||
RunE: todoNotImplemented,
|
||||
}
|
||||
)
|
||||
|
||||
func startNodeCmd(node app.App) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "start",
|
||||
Short: "Run the full node",
|
||||
RunE: todoNotImplemented,
|
||||
}
|
||||
return cmd
|
||||
}
|
||||
|
||||
func nodeCommand(node app.App) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "node",
|
||||
Short: "Run the full node",
|
||||
RunE: todoNotImplemented,
|
||||
}
|
||||
cmd.AddCommand(
|
||||
initNodeCmd,
|
||||
startNodeCmd(node),
|
||||
resetNodeCmd,
|
||||
)
|
||||
return cmd
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package main
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
var (
|
||||
versionCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Print the app version",
|
||||
RunE: todoNotImplemented,
|
||||
}
|
||||
)
|
Loading…
Reference in New Issue