forked from umbracle/ethgo
-
Notifications
You must be signed in to change notification settings - Fork 3
/
abigen.go
53 lines (42 loc) · 1.13 KB
/
abigen.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
48
49
50
51
52
53
package commands
import (
"github.com/cloudwalk/ethgo/cmd/abigen"
flag "github.com/spf13/pflag"
)
// VersionCommand is the command to show the version of the agent
type AbigenCommand struct {
*baseCommand
source string
pckg string
output string
}
// Help implements the cli.Command interface
func (c *AbigenCommand) Help() string {
return `Usage: ethgo abigen
Compute the abigen.
` + c.Flags().FlagUsages()
}
// Synopsis implements the cli.Command interface
func (c *AbigenCommand) Synopsis() string {
return "Compute the abigen"
}
func (c *AbigenCommand) Flags() *flag.FlagSet {
flags := c.baseCommand.Flags("abigen")
flags.StringVar(&c.source, "source", "", "Source data")
flags.StringVar(&c.pckg, "package", "main", "Name of the package")
flags.StringVar(&c.output, "output", ".", "Output directory")
return flags
}
// Run implements the cli.Command interface
func (c *AbigenCommand) Run(args []string) int {
flags := c.Flags()
if err := flags.Parse(args); err != nil {
c.UI.Error(err.Error())
return 1
}
if err := abigen.Parse(c.source, c.pckg, c.output); err != nil {
c.UI.Error(err.Error())
return 1
}
return 0
}