Skip to content

Commit

Permalink
cmd/*: port to cli/v2
Browse files Browse the repository at this point in the history
  • Loading branch information
willianpaixao committed May 4, 2022
1 parent d73df89 commit f763a9e
Show file tree
Hide file tree
Showing 53 changed files with 805 additions and 760 deletions.
2 changes: 1 addition & 1 deletion cmd/abigen/main.go
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/internal/flags"
"github.com/ethereum/go-ethereum/log"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli/v2"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion cmd/checkpoint-admin/common.go
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rpc"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli/v2"
)

// newClient creates a client with specified remote URL.
Expand Down
2 changes: 1 addition & 1 deletion cmd/checkpoint-admin/exec.go
Expand Up @@ -36,7 +36,7 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rpc"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli/v2"
)

var commandDeploy = cli.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/checkpoint-admin/main.go
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/ethereum/go-ethereum/common/fdlimit"
"github.com/ethereum/go-ethereum/internal/flags"
"github.com/ethereum/go-ethereum/log"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli/v2"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion cmd/checkpoint-admin/status.go
Expand Up @@ -21,7 +21,7 @@ import (

"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli/v2"
)

var commandStatus = cli.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/clef/main.go
Expand Up @@ -56,7 +56,7 @@ import (
"github.com/ethereum/go-ethereum/signer/storage"
"github.com/mattn/go-colorable"
"github.com/mattn/go-isatty"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli/v2"
)

const legalWarning = `
Expand Down
36 changes: 18 additions & 18 deletions cmd/devp2p/discv4cmd.go
Expand Up @@ -28,14 +28,14 @@ import (
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/params"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli/v2"
)

var (
discv4Command = cli.Command{
discv4Command = &cli.Command{
Name: "discv4",
Usage: "Node Discovery v4 tools",
Subcommands: []cli.Command{
Subcommands: []*cli.Command{
discv4PingCommand,
discv4RequestRecordCommand,
discv4ResolveCommand,
Expand All @@ -44,39 +44,39 @@ var (
discv4TestCommand,
},
}
discv4PingCommand = cli.Command{
discv4PingCommand = &cli.Command{
Name: "ping",
Usage: "Sends ping to a node",
Action: discv4Ping,
ArgsUsage: "<node>",
}
discv4RequestRecordCommand = cli.Command{
discv4RequestRecordCommand = &cli.Command{
Name: "requestenr",
Usage: "Requests a node record using EIP-868 enrRequest",
Action: discv4RequestRecord,
ArgsUsage: "<node>",
}
discv4ResolveCommand = cli.Command{
discv4ResolveCommand = &cli.Command{
Name: "resolve",
Usage: "Finds a node in the DHT",
Action: discv4Resolve,
ArgsUsage: "<node>",
Flags: []cli.Flag{bootnodesFlag},
}
discv4ResolveJSONCommand = cli.Command{
discv4ResolveJSONCommand = &cli.Command{
Name: "resolve-json",
Usage: "Re-resolves nodes in a nodes.json file",
Action: discv4ResolveJSON,
Flags: []cli.Flag{bootnodesFlag},
ArgsUsage: "<nodes.json file>",
}
discv4CrawlCommand = cli.Command{
discv4CrawlCommand = &cli.Command{
Name: "crawl",
Usage: "Updates a nodes.json file with random nodes found in the DHT",
Action: discv4Crawl,
Flags: []cli.Flag{bootnodesFlag, crawlTimeoutFlag},
}
discv4TestCommand = cli.Command{
discv4TestCommand = &cli.Command{
Name: "test",
Usage: "Runs tests against a node",
Action: discv4Test,
Expand All @@ -91,31 +91,31 @@ var (
)

var (
bootnodesFlag = cli.StringFlag{
bootnodesFlag = &cli.StringFlag{
Name: "bootnodes",
Usage: "Comma separated nodes used for bootstrapping",
}
nodekeyFlag = cli.StringFlag{
nodekeyFlag = &cli.StringFlag{
Name: "nodekey",
Usage: "Hex-encoded node key",
}
nodedbFlag = cli.StringFlag{
nodedbFlag = &cli.StringFlag{
Name: "nodedb",
Usage: "Nodes database location",
}
listenAddrFlag = cli.StringFlag{
listenAddrFlag = &cli.StringFlag{
Name: "addr",
Usage: "Listening address",
}
crawlTimeoutFlag = cli.DurationFlag{
crawlTimeoutFlag = &cli.DurationFlag{
Name: "timeout",
Usage: "Time limit for the crawl.",
Value: 30 * time.Minute,
}
remoteEnodeFlag = cli.StringFlag{
Name: "remote",
Usage: "Enode of the remote node under test",
EnvVar: "REMOTE_ENODE",
remoteEnodeFlag = &cli.StringFlag{
Name: "remote",
Usage: "Enode of the remote node under test",
EnvVars: []string{"REMOTE_ENODE"},
}
)

Expand Down
16 changes: 8 additions & 8 deletions cmd/devp2p/discv5cmd.go
Expand Up @@ -23,39 +23,39 @@ import (
"github.com/ethereum/go-ethereum/cmd/devp2p/internal/v5test"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/p2p/discover"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli/v2"
)

var (
discv5Command = cli.Command{
discv5Command = &cli.Command{
Name: "discv5",
Usage: "Node Discovery v5 tools",
Subcommands: []cli.Command{
Subcommands: []*cli.Command{
discv5PingCommand,
discv5ResolveCommand,
discv5CrawlCommand,
discv5TestCommand,
discv5ListenCommand,
},
}
discv5PingCommand = cli.Command{
discv5PingCommand = &cli.Command{
Name: "ping",
Usage: "Sends ping to a node",
Action: discv5Ping,
}
discv5ResolveCommand = cli.Command{
discv5ResolveCommand = &cli.Command{
Name: "resolve",
Usage: "Finds a node in the DHT",
Action: discv5Resolve,
Flags: []cli.Flag{bootnodesFlag},
}
discv5CrawlCommand = cli.Command{
discv5CrawlCommand = &cli.Command{
Name: "crawl",
Usage: "Updates a nodes.json file with random nodes found in the DHT",
Action: discv5Crawl,
Flags: []cli.Flag{bootnodesFlag, crawlTimeoutFlag},
}
discv5TestCommand = cli.Command{
discv5TestCommand = &cli.Command{
Name: "test",
Usage: "Runs protocol tests against a node",
Action: discv5Test,
Expand All @@ -66,7 +66,7 @@ var (
testListen2Flag,
},
}
discv5ListenCommand = cli.Command{
discv5ListenCommand = &cli.Command{
Name: "listen",
Usage: "Runs a node",
Action: discv5Listen,
Expand Down
12 changes: 6 additions & 6 deletions cmd/devp2p/dns_cloudflare.go
Expand Up @@ -24,16 +24,16 @@ import (
"github.com/cloudflare/cloudflare-go"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/p2p/dnsdisc"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli/v2"
)

var (
cloudflareTokenFlag = cli.StringFlag{
Name: "token",
Usage: "CloudFlare API token",
EnvVar: "CLOUDFLARE_API_TOKEN",
cloudflareTokenFlag = &cli.StringFlag{
Name: "token",
Usage: "CloudFlare API token",
EnvVars: []string{"CLOUDFLARE_API_TOKEN"},
}
cloudflareZoneIDFlag = cli.StringFlag{
cloudflareZoneIDFlag = &cli.StringFlag{
Name: "zoneid",
Usage: "CloudFlare Zone ID (optional)",
}
Expand Down
22 changes: 11 additions & 11 deletions cmd/devp2p/dns_route53.go
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/aws/aws-sdk-go-v2/service/route53/types"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/p2p/dnsdisc"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli/v2"
)

const (
Expand All @@ -45,21 +45,21 @@ const (
)

var (
route53AccessKeyFlag = cli.StringFlag{
Name: "access-key-id",
Usage: "AWS Access Key ID",
EnvVar: "AWS_ACCESS_KEY_ID",
route53AccessKeyFlag = &cli.StringFlag{
Name: "access-key-id",
Usage: "AWS Access Key ID",
EnvVars: []string{"AWS_ACCESS_KEY_ID"},
}
route53AccessSecretFlag = cli.StringFlag{
Name: "access-key-secret",
Usage: "AWS Access Key Secret",
EnvVar: "AWS_SECRET_ACCESS_KEY",
route53AccessSecretFlag = &cli.StringFlag{
Name: "access-key-secret",
Usage: "AWS Access Key gnSecret",
EnvVars: []string{"AWS_SECRET_ACCESS_KEY"},
}
route53ZoneIDFlag = cli.StringFlag{
route53ZoneIDFlag = &cli.StringFlag{
Name: "zone-id",
Usage: "Route53 Zone ID",
}
route53RegionFlag = cli.StringFlag{
route53RegionFlag = &cli.StringFlag{
Name: "aws-region",
Usage: "AWS Region",
Value: "eu-central-1",
Expand Down
24 changes: 12 additions & 12 deletions cmd/devp2p/dnscmd.go
Expand Up @@ -30,14 +30,14 @@ import (
"github.com/ethereum/go-ethereum/console/prompt"
"github.com/ethereum/go-ethereum/p2p/dnsdisc"
"github.com/ethereum/go-ethereum/p2p/enode"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli/v2"
)

var (
dnsCommand = cli.Command{
dnsCommand = &cli.Command{
Name: "dns",
Usage: "DNS Discovery Commands",
Subcommands: []cli.Command{
Subcommands: []*cli.Command{
dnsSyncCommand,
dnsSignCommand,
dnsTXTCommand,
Expand All @@ -46,34 +46,34 @@ var (
dnsRoute53NukeCommand,
},
}
dnsSyncCommand = cli.Command{
dnsSyncCommand = &cli.Command{
Name: "sync",
Usage: "Download a DNS discovery tree",
ArgsUsage: "<url> [ <directory> ]",
Action: dnsSync,
Flags: []cli.Flag{dnsTimeoutFlag},
}
dnsSignCommand = cli.Command{
dnsSignCommand = &cli.Command{
Name: "sign",
Usage: "Sign a DNS discovery tree",
ArgsUsage: "<tree-directory> <key-file>",
Action: dnsSign,
Flags: []cli.Flag{dnsDomainFlag, dnsSeqFlag},
}
dnsTXTCommand = cli.Command{
dnsTXTCommand = &cli.Command{
Name: "to-txt",
Usage: "Create a DNS TXT records for a discovery tree",
ArgsUsage: "<tree-directory> <output-file>",
Action: dnsToTXT,
}
dnsCloudflareCommand = cli.Command{
dnsCloudflareCommand = &cli.Command{
Name: "to-cloudflare",
Usage: "Deploy DNS TXT records to CloudFlare",
ArgsUsage: "<tree-directory>",
Action: dnsToCloudflare,
Flags: []cli.Flag{cloudflareTokenFlag, cloudflareZoneIDFlag},
}
dnsRoute53Command = cli.Command{
dnsRoute53Command = &cli.Command{
Name: "to-route53",
Usage: "Deploy DNS TXT records to Amazon Route53",
ArgsUsage: "<tree-directory>",
Expand All @@ -85,7 +85,7 @@ var (
route53RegionFlag,
},
}
dnsRoute53NukeCommand = cli.Command{
dnsRoute53NukeCommand = &cli.Command{
Name: "nuke-route53",
Usage: "Deletes DNS TXT records of a subdomain on Amazon Route53",
ArgsUsage: "<domain>",
Expand All @@ -100,15 +100,15 @@ var (
)

var (
dnsTimeoutFlag = cli.DurationFlag{
dnsTimeoutFlag = &cli.DurationFlag{
Name: "timeout",
Usage: "Timeout for DNS lookups",
}
dnsDomainFlag = cli.StringFlag{
dnsDomainFlag = &cli.StringFlag{
Name: "domain",
Usage: "Domain name of the tree",
}
dnsSeqFlag = cli.UintFlag{
dnsSeqFlag = &cli.UintFlag{
Name: "seq",
Usage: "New sequence number of the tree",
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/devp2p/enrcmd.go
Expand Up @@ -31,12 +31,12 @@ import (
"github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/p2p/enr"
"github.com/ethereum/go-ethereum/rlp"
"gopkg.in/urfave/cli.v1"
"github.com/urfave/cli/v2"
)

var fileFlag = cli.StringFlag{Name: "file"}
var fileFlag = &cli.StringFlag{Name: "file"}

var enrdumpCommand = cli.Command{
var enrdumpCommand = &cli.Command{
Name: "enrdump",
Usage: "Pretty-prints node records",
Action: enrdump,
Expand All @@ -63,7 +63,7 @@ func enrdump(ctx *cli.Context) error {
}
source = string(b)
} else if ctx.NArg() == 1 {
source = ctx.Args()[0]
source = ctx.Args().First()
} else {
return fmt.Errorf("need record as argument")
}
Expand Down

0 comments on commit f763a9e

Please sign in to comment.