mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-04 19:19:44 +00:00
911be78cc7
It is useful in tests.
38 lines
837 B
Go
38 lines
837 B
Go
package util
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
vmcli "github.com/nspcc-dev/neo-go/pkg/vm/cli"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
// NewCommands returns util commands for neo-go CLI.
|
|
func NewCommands() []cli.Command {
|
|
return []cli.Command{
|
|
{
|
|
Name: "util",
|
|
Usage: "Various helper commands",
|
|
Subcommands: []cli.Command{
|
|
{
|
|
Name: "convert",
|
|
Usage: "Convert provided argument into other possible formats",
|
|
UsageText: `convert <arg>
|
|
|
|
<arg> is an argument which is tried to be interpreted as an item of different types
|
|
and converted to other formats. Strings are escaped and output in quotes.`,
|
|
Action: handleParse,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func handleParse(ctx *cli.Context) error {
|
|
res, err := vmcli.Parse(ctx.Args())
|
|
if err != nil {
|
|
return cli.NewExitError(err, 1)
|
|
}
|
|
fmt.Fprint(ctx.App.Writer, res)
|
|
return nil
|
|
}
|