-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* First iteration of the cmd * Update docs * Run plausible only on prod
- Loading branch information
Showing
22 changed files
with
476 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package commands | ||
|
||
import ( | ||
flag "github.com/spf13/pflag" | ||
"github.com/umbracle/ethgo/cmd/abigen" | ||
) | ||
|
||
// 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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package commands | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/mitchellh/cli" | ||
flag "github.com/spf13/pflag" | ||
) | ||
|
||
func Commands() map[string]cli.CommandFactory { | ||
ui := &cli.BasicUi{ | ||
Reader: os.Stdin, | ||
Writer: os.Stdout, | ||
ErrorWriter: os.Stderr, | ||
} | ||
|
||
baseCommand := &baseCommand{ | ||
UI: ui, | ||
} | ||
|
||
return map[string]cli.CommandFactory{ | ||
"abigen": func() (cli.Command, error) { | ||
return &AbigenCommand{ | ||
baseCommand: baseCommand, | ||
}, nil | ||
}, | ||
"version": func() (cli.Command, error) { | ||
return &VersionCommand{ | ||
UI: ui, | ||
}, nil | ||
}, | ||
} | ||
} | ||
|
||
type baseCommand struct { | ||
UI cli.Ui | ||
} | ||
|
||
func (b *baseCommand) Flags(name string) *flag.FlagSet { | ||
flags := flag.NewFlagSet(name, 0) | ||
return flags | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package commands | ||
|
||
import ( | ||
"github.com/mitchellh/cli" | ||
"github.com/umbracle/ethgo/cmd/version" | ||
) | ||
|
||
// VersionCommand is the command to show the version of the agent | ||
type VersionCommand struct { | ||
UI cli.Ui | ||
} | ||
|
||
// Help implements the cli.Command interface | ||
func (c *VersionCommand) Help() string { | ||
return `Usage: ethgo version | ||
Display the Ethgo version` | ||
} | ||
|
||
// Synopsis implements the cli.Command interface | ||
func (c *VersionCommand) Synopsis() string { | ||
return "Display the Ethgo version" | ||
} | ||
|
||
// Run implements the cli.Command interface | ||
func (c *VersionCommand) Run(args []string) int { | ||
c.UI.Output(version.GetVersion()) | ||
return 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module github.com/umbracle/ethgo/cmd | ||
|
||
go 1.17 | ||
|
||
require ( | ||
github.com/mitchellh/cli v1.1.2 | ||
github.com/umbracle/ethgo v0.0.0-20220303093617-1621d9ff042b | ||
) | ||
|
||
require ( | ||
github.com/Masterminds/goutils v1.1.0 // indirect | ||
github.com/Masterminds/semver v1.5.0 // indirect | ||
github.com/Masterminds/sprig v2.22.0+incompatible // indirect | ||
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 // indirect | ||
github.com/bgentry/speakeasy v0.1.0 // indirect | ||
github.com/fatih/color v1.7.0 // indirect | ||
github.com/google/gofuzz v1.2.0 // indirect | ||
github.com/google/uuid v1.1.2 // indirect | ||
github.com/hashicorp/errwrap v1.0.0 // indirect | ||
github.com/hashicorp/go-multierror v1.0.0 // indirect | ||
github.com/huandu/xstrings v1.3.2 // indirect | ||
github.com/imdario/mergo v0.3.11 // indirect | ||
github.com/mattn/go-colorable v0.0.9 // indirect | ||
github.com/mattn/go-isatty v0.0.3 // indirect | ||
github.com/mitchellh/copystructure v1.0.0 // indirect | ||
github.com/mitchellh/mapstructure v1.1.2 // indirect | ||
github.com/mitchellh/reflectwalk v1.0.0 // indirect | ||
github.com/posener/complete v1.1.1 // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
github.com/umbracle/fastrlp v0.0.0-20211229195328-c1416904ae17 // indirect | ||
github.com/valyala/fastjson v1.4.1 // indirect | ||
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect | ||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 // indirect | ||
) |
Oops, something went wrong.
8907487
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: