cli: refactor ibc and counter into own binaries
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
wire "github.com/tendermint/go-wire"
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/tendermint/basecoin/cmd/commands"
|
||||
"github.com/tendermint/basecoin/plugins/counter"
|
||||
"github.com/tendermint/basecoin/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
commands.RegisterTxSubcommand(CounterTxCmd)
|
||||
commands.RegisterStartPlugin("counter", func() types.Plugin {
|
||||
return counter.New("counter")
|
||||
})
|
||||
}
|
||||
|
||||
var (
|
||||
ValidFlag = cli.BoolFlag{
|
||||
Name: "valid",
|
||||
Usage: "Set valid field in CounterTx",
|
||||
}
|
||||
|
||||
CounterTxCmd = cli.Command{
|
||||
Name: "counter",
|
||||
Usage: "Create, sign, and broadcast a transaction to the counter plugin",
|
||||
Action: func(c *cli.Context) error {
|
||||
return cmdCounterTx(c)
|
||||
},
|
||||
Flags: append(commands.TxFlags, ValidFlag),
|
||||
}
|
||||
)
|
||||
|
||||
func cmdCounterTx(c *cli.Context) error {
|
||||
valid := c.Bool("valid")
|
||||
|
||||
counterTx := counter.CounterTx{
|
||||
Valid: valid,
|
||||
Fee: types.Coins{
|
||||
{
|
||||
Denom: c.String("coin"),
|
||||
Amount: int64(c.Int("fee")),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
fmt.Println("CounterTx:", string(wire.JSONBytes(counterTx)))
|
||||
|
||||
data := wire.BinaryBytes(counterTx)
|
||||
name := "counter"
|
||||
|
||||
return commands.AppTx(c, name, data)
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/tendermint/basecoin/cmd/commands"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := cli.NewApp()
|
||||
app.Name = "counter"
|
||||
app.Usage = "counter [command] [args...]"
|
||||
app.Version = "0.1.0"
|
||||
app.Commands = []cli.Command{
|
||||
commands.StartCmd,
|
||||
commands.TxCmd,
|
||||
commands.QueryCmd,
|
||||
commands.AccountCmd,
|
||||
}
|
||||
app.Run(os.Args)
|
||||
}
|
||||
Reference in New Issue
Block a user