-
Notifications
You must be signed in to change notification settings - Fork 79
/
convert.go
47 lines (42 loc) · 1.1 KB
/
convert.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package util
import (
"fmt"
"github.com/nspcc-dev/neo-go/cli/options"
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 {
txDumpFlags := append([]cli.Flag{}, options.RPC...)
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,
},
{
Name: "txdump",
Usage: "Dump transaction stored in file",
UsageText: "txdump [-r <endpoint>] <file.in>",
Action: txDump,
Flags: txDumpFlags,
},
},
},
}
}
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
}