mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
Adding exit codes to cli commands (#11735)
* adding exit codes to cmd * adding in fatal logs to other cli actions Co-authored-by: Radosław Kapka <rkapka@wp.pl>
This commit is contained in:
@@ -23,7 +23,12 @@ var Commands = &cli.Command{
|
||||
Flags: cmd.WrapFlags([]cli.Flag{
|
||||
cmd.JwtOutputFileFlag,
|
||||
}),
|
||||
Action: generateAuthSecretInFile,
|
||||
Action: func(cliCtx *cli.Context) error {
|
||||
if err := generateAuthSecretInFile(cliCtx); err != nil {
|
||||
logrus.WithError(err).Fatal("Could not generate jwt")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
func generateAuthSecretInFile(c *cli.Context) error {
|
||||
|
||||
@@ -140,7 +140,12 @@ func main() {
|
||||
app := cli.App{}
|
||||
app.Name = "beacon-chain"
|
||||
app.Usage = "this is a beacon chain implementation for Ethereum"
|
||||
app.Action = startNode
|
||||
app.Action = func(ctx *cli.Context) error {
|
||||
if err := startNode(ctx); err != nil {
|
||||
return cli.Exit(err.Error(), 1)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
app.Version = version.Version()
|
||||
app.Commands = []*cli.Command{
|
||||
dbcommands.Commands,
|
||||
|
||||
@@ -19,7 +19,12 @@ var downloadCmd = &cli.Command{
|
||||
Name: "download",
|
||||
Aliases: []string{"dl"},
|
||||
Usage: "Download the latest finalized state and the most recent block it integrates. To be used for checkpoint sync.",
|
||||
Action: cliActionDownload,
|
||||
Action: func(cliCtx *cli.Context) error {
|
||||
if err := cliActionDownload(cliCtx); err != nil {
|
||||
log.WithError(err).Fatal("Could not download checkpoint-sync data")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "beacon-node-host",
|
||||
|
||||
@@ -21,9 +21,14 @@ var queryFlags = struct {
|
||||
}{}
|
||||
|
||||
var queryCmd = &cli.Command{
|
||||
Name: "query",
|
||||
Usage: "database query tool",
|
||||
Action: queryAction,
|
||||
Name: "query",
|
||||
Usage: "database query tool",
|
||||
Action: func(cliCtx *cli.Context) error {
|
||||
if err := queryAction(cliCtx); err != nil {
|
||||
log.WithError(err).Fatal("Could not query db")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "bucket",
|
||||
|
||||
@@ -32,9 +32,14 @@ var requestBlocksFlags = struct {
|
||||
}{}
|
||||
|
||||
var requestBlocksCmd = &cli.Command{
|
||||
Name: "beacon-blocks-by-range",
|
||||
Usage: "Request a range of blocks from a beacon node via a p2p connection",
|
||||
Action: cliActionRequestBlocks,
|
||||
Name: "beacon-blocks-by-range",
|
||||
Usage: "Request a range of blocks from a beacon node via a p2p connection",
|
||||
Action: func(cliCtx *cli.Context) error {
|
||||
if err := cliActionRequestBlocks(cliCtx); err != nil {
|
||||
log.WithError(err).Fatal("Could not request blocks by range")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
cmd.ChainConfigFileFlag,
|
||||
&cli.StringFlag{
|
||||
|
||||
@@ -59,9 +59,14 @@ var (
|
||||
Value: "",
|
||||
}
|
||||
generateGenesisStateCmd = &cli.Command{
|
||||
Name: "generate-genesis",
|
||||
Usage: "Generate a beacon chain genesis state",
|
||||
Action: cliActionGenerateGenesisState,
|
||||
Name: "generate-genesis",
|
||||
Usage: "Generate a beacon chain genesis state",
|
||||
Action: func(cliCtx *cli.Context) error {
|
||||
if err := cliActionGenerateGenesisState(cliCtx); err != nil {
|
||||
log.WithError(err).Fatal("Could not generate beacon chain genesis state")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "chain-config-file",
|
||||
|
||||
@@ -10,6 +10,7 @@ go_library(
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//api/client/beacon:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
"@com_github_urfave_cli_v2//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/v3/api/client/beacon"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
@@ -18,7 +19,12 @@ var checkpointCmd = &cli.Command{
|
||||
Name: "checkpoint",
|
||||
Aliases: []string{"cpt"},
|
||||
Usage: "Compute the latest weak subjectivity checkpoint (block_root:epoch) using trusted server data.",
|
||||
Action: cliActionCheckpoint,
|
||||
Action: func(cliCtx *cli.Context) error {
|
||||
if err := cliActionCheckpoint(cliCtx); err != nil {
|
||||
log.WithError(err).Fatal("Could not perform checkpoint-sync")
|
||||
}
|
||||
return nil
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "beacon-node-host",
|
||||
|
||||
@@ -121,7 +121,12 @@ func main() {
|
||||
app.Name = "validator"
|
||||
app.Usage = `launches an Ethereum validator client that interacts with a beacon chain, starts proposer and attester services, p2p connections, and more`
|
||||
app.Version = version.Version()
|
||||
app.Action = startNode
|
||||
app.Action = func(ctx *cli.Context) error {
|
||||
if err := startNode(ctx); err != nil {
|
||||
return cli.Exit(err.Error(), 1)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
app.Commands = []*cli.Command{
|
||||
walletcommands.Commands,
|
||||
accountcommands.Commands,
|
||||
|
||||
Reference in New Issue
Block a user