Add helper function to print usage when wrong number of arguments are supplied

This commit is contained in:
Geoff Stuart 2022-09-14 15:38:15 -04:00
parent 3ca9b1e331
commit 4f75e2041c
39 changed files with 108 additions and 102 deletions

View File

@ -115,7 +115,7 @@ this command must be within this base path`,
ArgsUsage: "[backup file path]", ArgsUsage: "[backup file path]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return xerrors.Errorf("expected 1 argument") return IncorrectNumArgs(cctx)
} }
if cctx.Bool("offline") { if cctx.Bool("offline") {

View File

@ -947,7 +947,7 @@ var ChainBisectCmd = &cli.Command{
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
if cctx.NArg() < 4 { if cctx.NArg() < 4 {
return xerrors.New("need at least 4 args") return IncorrectNumArgs(cctx)
} }
start, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64) start, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64)
@ -1313,7 +1313,7 @@ var chainDecodeParamsCmd = &cli.Command{
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
if cctx.NArg() != 3 { if cctx.NArg() != 3 {
return ShowHelp(cctx, fmt.Errorf("incorrect number of arguments")) return IncorrectNumArgs(cctx)
} }
to, err := address.NewFromString(cctx.Args().First()) to, err := address.NewFromString(cctx.Args().First())
@ -1392,7 +1392,7 @@ var chainEncodeParamsCmd = &cli.Command{
afmt := NewAppFmt(cctx.App) afmt := NewAppFmt(cctx.App)
if cctx.NArg() != 3 { if cctx.NArg() != 3 {
return ShowHelp(cctx, fmt.Errorf("incorrect number of arguments")) return IncorrectNumArgs(cctx)
} }
method, err := strconv.ParseInt(cctx.Args().Get(1), 10, 64) method, err := strconv.ParseInt(cctx.Args().Get(1), 10, 64)

View File

@ -130,7 +130,7 @@ var clientImportCmd = &cli.Command{
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return xerrors.New("expected input path as the only arg") return IncorrectNumArgs(cctx)
} }
absPath, err := filepath.Abs(cctx.Args().First()) absPath, err := filepath.Abs(cctx.Args().First())
@ -213,7 +213,7 @@ var clientCommPCmd = &cli.Command{
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return fmt.Errorf("usage: commP <inputPath>") return IncorrectNumArgs(cctx)
} }
ret, err := api.ClientCalcCommP(ctx, cctx.Args().Get(0)) ret, err := api.ClientCalcCommP(ctx, cctx.Args().Get(0))
@ -246,7 +246,7 @@ var clientCarGenCmd = &cli.Command{
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return fmt.Errorf("usage: generate-car <inputPath> <outputPath>") return IncorrectNumArgs(cctx)
} }
ref := lapi.FileRef{ ref := lapi.FileRef{
@ -376,7 +376,7 @@ The minimum value is 518400 (6 months).`,
afmt := NewAppFmt(cctx.App) afmt := NewAppFmt(cctx.App)
if cctx.NArg() != 4 { if cctx.NArg() != 4 {
return xerrors.New(expectedArgsMsg) return IncorrectNumArgs(cctx)
} }
// [data, miner, price, dur] // [data, miner, price, dur]

View File

@ -289,7 +289,7 @@ Examples:
}, retrFlagsCommon...), }, retrFlagsCommon...),
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return ShowHelp(cctx, fmt.Errorf("incorrect number of arguments")) return IncorrectNumArgs(cctx)
} }
if cctx.Bool("car-export-merkle-proof") { if cctx.Bool("car-export-merkle-proof") {
@ -405,7 +405,7 @@ var clientRetrieveCatCmd = &cli.Command{
}, retrFlagsCommon...), }, retrFlagsCommon...),
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return ShowHelp(cctx, fmt.Errorf("incorrect number of arguments")) return IncorrectNumArgs(cctx)
} }
ainfo, err := GetAPIInfo(cctx, repo.FullNode) ainfo, err := GetAPIInfo(cctx, repo.FullNode)
@ -484,7 +484,7 @@ var clientRetrieveLsCmd = &cli.Command{
}, retrFlagsCommon...), }, retrFlagsCommon...),
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return ShowHelp(cctx, fmt.Errorf("incorrect number of arguments")) return IncorrectNumArgs(cctx)
} }
ainfo, err := GetAPIInfo(cctx, repo.FullNode) ainfo, err := GetAPIInfo(cctx, repo.FullNode)

View File

@ -62,7 +62,7 @@ var filplusVerifyClientCmd = &cli.Command{
} }
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return fmt.Errorf("must specify two arguments: address and allowance") return IncorrectNumArgs(cctx)
} }
target, err := address.NewFromString(cctx.Args().Get(0)) target, err := address.NewFromString(cctx.Args().Get(0))
@ -290,7 +290,7 @@ var filplusSignRemoveDataCapProposal = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 3 { if cctx.NArg() != 3 {
return fmt.Errorf("must specify three arguments: notary address, client address, and allowance to remove") return IncorrectNumArgs(cctx)
} }
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)

View File

@ -31,6 +31,10 @@ func ShowHelp(cctx *ufcli.Context, err error) error {
return &PrintHelpErr{Err: err, Ctx: cctx} return &PrintHelpErr{Err: err, Ctx: cctx}
} }
func IncorrectNumArgs(cctx *ufcli.Context) error {
return ShowHelp(cctx, fmt.Errorf("incorrect number of arguments, got %d", cctx.NArg()))
}
func RunApp(app *ufcli.App) { func RunApp(app *ufcli.App) {
if err := app.Run(os.Args); err != nil { if err := app.Run(os.Args); err != nil {
if os.Getenv("LOTUS_DEV") != "" { if os.Getenv("LOTUS_DEV") != "" {

View File

@ -611,7 +611,7 @@ var MpoolConfig = &cli.Command{
ArgsUsage: "[new-config]", ArgsUsage: "[new-config]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() > 1 { if cctx.NArg() > 1 {
return cli.ShowCommandHelp(cctx, cctx.Command.Name) return IncorrectNumArgs(cctx)
} }
afmt := NewAppFmt(cctx.App) afmt := NewAppFmt(cctx.App)

View File

@ -89,7 +89,7 @@ var msigCreateCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() < 1 { if cctx.NArg() < 1 {
return ShowHelp(cctx, fmt.Errorf("multisigs must have at least one signer")) return IncorrectNumArgs(cctx)
} }
srv, err := GetFullNodeServices(cctx) srv, err := GetFullNodeServices(cctx)
@ -754,7 +754,7 @@ var msigRemoveProposeCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return ShowHelp(cctx, fmt.Errorf("must pass multisig address and signer address")) return IncorrectNumArgs(cctx)
} }
srv, err := GetFullNodeServices(cctx) srv, err := GetFullNodeServices(cctx)
@ -841,7 +841,7 @@ var msigAddProposeCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return ShowHelp(cctx, fmt.Errorf("must pass multisig address and signer address")) return IncorrectNumArgs(cctx)
} }
srv, err := GetFullNodeServices(cctx) srv, err := GetFullNodeServices(cctx)
@ -950,7 +950,7 @@ var msigAddApproveCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 5 { if cctx.NArg() != 5 {
return ShowHelp(cctx, fmt.Errorf("must pass multisig address, proposer address, transaction id, new signer address, whether to increase threshold")) return IncorrectNumArgs(cctx)
} }
srv, err := GetFullNodeServices(cctx) srv, err := GetFullNodeServices(cctx)
@ -1041,7 +1041,7 @@ var msigAddCancelCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 4 { if cctx.NArg() != 4 {
return ShowHelp(cctx, fmt.Errorf("must pass multisig address, transaction id, new signer address, whether to increase threshold")) return IncorrectNumArgs(cctx)
} }
srv, err := GetFullNodeServices(cctx) srv, err := GetFullNodeServices(cctx)
@ -1127,7 +1127,7 @@ var msigSwapProposeCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 3 { if cctx.NArg() != 3 {
return ShowHelp(cctx, fmt.Errorf("must pass multisig address, old signer address, new signer address")) return IncorrectNumArgs(cctx)
} }
srv, err := GetFullNodeServices(cctx) srv, err := GetFullNodeServices(cctx)
@ -1208,7 +1208,7 @@ var msigSwapApproveCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 5 { if cctx.NArg() != 5 {
return ShowHelp(cctx, fmt.Errorf("must pass multisig address, proposer address, transaction id, old signer address, new signer address")) return IncorrectNumArgs(cctx)
} }
srv, err := GetFullNodeServices(cctx) srv, err := GetFullNodeServices(cctx)
@ -1299,7 +1299,7 @@ var msigSwapCancelCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 4 { if cctx.NArg() != 4 {
return ShowHelp(cctx, fmt.Errorf("must pass multisig address, transaction id, old signer address, new signer address")) return IncorrectNumArgs(cctx)
} }
srv, err := GetFullNodeServices(cctx) srv, err := GetFullNodeServices(cctx)
@ -1385,7 +1385,7 @@ var msigLockProposeCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 4 { if cctx.NArg() != 4 {
return ShowHelp(cctx, fmt.Errorf("must pass multisig address, start epoch, unlock duration, and amount")) return IncorrectNumArgs(cctx)
} }
srv, err := GetFullNodeServices(cctx) srv, err := GetFullNodeServices(cctx)
@ -1481,7 +1481,7 @@ var msigLockApproveCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 6 { if cctx.NArg() != 6 {
return ShowHelp(cctx, fmt.Errorf("must pass multisig address, proposer address, tx id, start epoch, unlock duration, and amount")) return IncorrectNumArgs(cctx)
} }
srv, err := GetFullNodeServices(cctx) srv, err := GetFullNodeServices(cctx)
@ -1587,7 +1587,7 @@ var msigLockCancelCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 5 { if cctx.NArg() != 5 {
return ShowHelp(cctx, fmt.Errorf("must pass multisig address, tx id, start epoch, unlock duration, and amount")) return IncorrectNumArgs(cctx)
} }
srv, err := GetFullNodeServices(cctx) srv, err := GetFullNodeServices(cctx)
@ -1694,7 +1694,7 @@ var msigVestedCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return ShowHelp(cctx, fmt.Errorf("must pass multisig address")) return IncorrectNumArgs(cctx)
} }
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)
@ -1750,7 +1750,7 @@ var msigProposeThresholdCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return ShowHelp(cctx, fmt.Errorf("must pass multisig address and new threshold value")) return IncorrectNumArgs(cctx)
} }
srv, err := GetFullNodeServices(cctx) srv, err := GetFullNodeServices(cctx)

View File

@ -142,7 +142,7 @@ var NetPing = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return xerrors.Errorf("please provide a peerID") return IncorrectNumArgs(cctx)
} }
api, closer, err := GetAPI(cctx) api, closer, err := GetAPI(cctx)

View File

@ -51,7 +51,7 @@ var paychAddFundsCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 3 { if cctx.NArg() != 3 {
return ShowHelp(cctx, fmt.Errorf("must pass three arguments: <from> <to> <available funds>")) return IncorrectNumArgs(cctx)
} }
from, err := address.NewFromString(cctx.Args().Get(0)) from, err := address.NewFromString(cctx.Args().Get(0))
@ -113,7 +113,7 @@ var paychStatusByFromToCmd = &cli.Command{
ArgsUsage: "[fromAddress toAddress]", ArgsUsage: "[fromAddress toAddress]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return ShowHelp(cctx, fmt.Errorf("must pass two arguments: <from address> <to address>")) return IncorrectNumArgs(cctx)
} }
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
@ -149,7 +149,7 @@ var paychStatusCmd = &cli.Command{
ArgsUsage: "[channelAddress]", ArgsUsage: "[channelAddress]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return ShowHelp(cctx, fmt.Errorf("must pass an argument: <channel address>")) return IncorrectNumArgs(cctx)
} }
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
@ -261,7 +261,7 @@ var paychSettleCmd = &cli.Command{
ArgsUsage: "[channelAddress]", ArgsUsage: "[channelAddress]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return fmt.Errorf("must pass payment channel address") return IncorrectNumArgs(cctx)
} }
ch, err := address.NewFromString(cctx.Args().Get(0)) ch, err := address.NewFromString(cctx.Args().Get(0))
@ -301,7 +301,7 @@ var paychCloseCmd = &cli.Command{
ArgsUsage: "[channelAddress]", ArgsUsage: "[channelAddress]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return fmt.Errorf("must pass payment channel address") return IncorrectNumArgs(cctx)
} }
ch, err := address.NewFromString(cctx.Args().Get(0)) ch, err := address.NewFromString(cctx.Args().Get(0))
@ -361,7 +361,7 @@ var paychVoucherCreateCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return ShowHelp(cctx, fmt.Errorf("must pass two arguments: <channel> <amount>")) return IncorrectNumArgs(cctx)
} }
ch, err := address.NewFromString(cctx.Args().Get(0)) ch, err := address.NewFromString(cctx.Args().Get(0))
@ -409,7 +409,7 @@ var paychVoucherCheckCmd = &cli.Command{
ArgsUsage: "[channelAddress voucher]", ArgsUsage: "[channelAddress voucher]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return ShowHelp(cctx, fmt.Errorf("must pass payment channel address and voucher to validate")) return IncorrectNumArgs(cctx)
} }
ch, err := address.NewFromString(cctx.Args().Get(0)) ch, err := address.NewFromString(cctx.Args().Get(0))
@ -445,7 +445,7 @@ var paychVoucherAddCmd = &cli.Command{
ArgsUsage: "[channelAddress voucher]", ArgsUsage: "[channelAddress voucher]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return ShowHelp(cctx, fmt.Errorf("must pass payment channel address and voucher")) return IncorrectNumArgs(cctx)
} }
ch, err := address.NewFromString(cctx.Args().Get(0)) ch, err := address.NewFromString(cctx.Args().Get(0))
@ -487,7 +487,7 @@ var paychVoucherListCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return ShowHelp(cctx, fmt.Errorf("must pass payment channel address")) return IncorrectNumArgs(cctx)
} }
ch, err := address.NewFromString(cctx.Args().Get(0)) ch, err := address.NewFromString(cctx.Args().Get(0))
@ -532,7 +532,7 @@ var paychVoucherBestSpendableCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return ShowHelp(cctx, fmt.Errorf("must pass payment channel address")) return IncorrectNumArgs(cctx)
} }
ch, err := address.NewFromString(cctx.Args().Get(0)) ch, err := address.NewFromString(cctx.Args().Get(0))
@ -603,7 +603,7 @@ var paychVoucherSubmitCmd = &cli.Command{
ArgsUsage: "[channelAddress voucher]", ArgsUsage: "[channelAddress voucher]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return ShowHelp(cctx, fmt.Errorf("must pass payment channel address and voucher")) return IncorrectNumArgs(cctx)
} }
ch, err := address.NewFromString(cctx.Args().Get(0)) ch, err := address.NewFromString(cctx.Args().Get(0))

View File

@ -68,7 +68,7 @@ var sendCmd = &cli.Command{
} }
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return ShowHelp(cctx, fmt.Errorf("'send' expects two arguments, target and amount")) return IncorrectNumArgs(cctx)
} }
srv, err := GetFullNodeServices(cctx) srv, err := GetFullNodeServices(cctx)

View File

@ -505,8 +505,7 @@ var StateReplayCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
fmt.Println("must provide cid of message to replay") return IncorrectNumArgs(cctx)
return nil
} }
mcid, err := cid.Decode(cctx.Args().First()) mcid, err := cid.Decode(cctx.Args().First())
@ -1581,7 +1580,7 @@ var StateCallCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() < 2 { if cctx.NArg() < 2 {
return fmt.Errorf("must specify at least actor and method to invoke") return ShowHelp(cctx, fmt.Errorf("must specify at least actor and method to invoke"))
} }
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)
@ -1744,7 +1743,7 @@ var StateSectorCmd = &cli.Command{
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return xerrors.Errorf("expected 2 params: minerAddress and sectorNumber") return IncorrectNumArgs(cctx)
} }
ts, err := LoadTipSet(ctx, cctx, api) ts, err := LoadTipSet(ctx, cctx, api)

View File

@ -729,7 +729,7 @@ var actorSetOwnerCmd = &cli.Command{
} }
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return fmt.Errorf("must pass new owner address and sender address") return lcli.IncorrectNumArgs(cctx)
} }
api, acloser, err := lcli.GetFullNodeAPI(cctx) api, acloser, err := lcli.GetFullNodeAPI(cctx)

View File

@ -77,7 +77,7 @@ var dagstoreRegisterShardCmd = &cli.Command{
} }
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return fmt.Errorf("must provide a single shard key") return lcli.IncorrectNumArgs(cctx)
} }
marketsAPI, closer, err := lcli.GetMarketsAPI(cctx) marketsAPI, closer, err := lcli.GetMarketsAPI(cctx)
@ -116,7 +116,7 @@ var dagstoreInitializeShardCmd = &cli.Command{
} }
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return fmt.Errorf("must provide a single shard key") return lcli.IncorrectNumArgs(cctx)
} }
marketsApi, closer, err := lcli.GetMarketsAPI(cctx) marketsApi, closer, err := lcli.GetMarketsAPI(cctx)
@ -148,7 +148,7 @@ var dagstoreRecoverShardCmd = &cli.Command{
} }
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return fmt.Errorf("must provide a single shard key") return lcli.IncorrectNumArgs(cctx)
} }
marketsApi, closer, err := lcli.GetMarketsAPI(cctx) marketsApi, closer, err := lcli.GetMarketsAPI(cctx)
@ -330,7 +330,7 @@ var dagstoreLookupPiecesCmd = &cli.Command{
} }
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return fmt.Errorf("must provide a CID") return lcli.IncorrectNumArgs(cctx)
} }
cidStr := cctx.Args().First() cidStr := cctx.Args().First()

View File

@ -36,7 +36,7 @@ var indexProvAnnounceCmd = &cli.Command{
} }
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return fmt.Errorf("must provide the deal proposal CID") return lcli.IncorrectNumArgs(cctx)
} }
proposalCidStr := cctx.Args().First() proposalCidStr := cctx.Args().First()

View File

@ -97,7 +97,7 @@ var restoreCmd = &cli.Command{
func restore(ctx context.Context, cctx *cli.Context, targetPath string, strConfig *paths.StorageConfig, manageConfig func(*config.StorageMiner) error, after func(api lapi.FullNode, addr address.Address, peerid peer.ID, mi api.MinerInfo) error) error { func restore(ctx context.Context, cctx *cli.Context, targetPath string, strConfig *paths.StorageConfig, manageConfig func(*config.StorageMiner) error, after func(api lapi.FullNode, addr address.Address, peerid peer.ID, mi api.MinerInfo) error) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return xerrors.Errorf("expected 1 argument") return lcli.IncorrectNumArgs(cctx)
} }
log.Info("Trying to connect to full node RPC") log.Info("Trying to connect to full node RPC")

View File

@ -370,8 +370,8 @@ var dealsImportDataCmd = &cli.Command{
ctx := lcli.DaemonContext(cctx) ctx := lcli.DaemonContext(cctx)
if cctx.NArg() < 2 { if cctx.NArg() != 2 {
return fmt.Errorf("must specify proposal CID and file path") return lcli.IncorrectNumArgs(cctx)
} }
propCid, err := cid.Decode(cctx.Args().Get(0)) propCid, err := cid.Decode(cctx.Args().Get(0))
@ -618,7 +618,7 @@ var setSealDurationCmd = &cli.Command{
defer closer() defer closer()
ctx := lcli.ReqContext(cctx) ctx := lcli.ReqContext(cctx)
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return xerrors.Errorf("must pass duration in minutes") return lcli.IncorrectNumArgs(cctx)
} }
hs, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64) hs, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64)

View File

@ -315,7 +315,7 @@ var provingDeadlineInfoCmd = &cli.Command{
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return xerrors.Errorf("must pass deadline index") return lcli.IncorrectNumArgs(cctx)
} }
dlIdx, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64) dlIdx, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64)
@ -462,7 +462,7 @@ var provingCheckProvableCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return xerrors.Errorf("must pass deadline index") return lcli.IncorrectNumArgs(cctx)
} }
dlIdx, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64) dlIdx, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64)
@ -617,7 +617,7 @@ It will not send any messages to the chain.`,
ArgsUsage: "[deadline index]", ArgsUsage: "[deadline index]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return xerrors.Errorf("must pass deadline index") return lcli.IncorrectNumArgs(cctx)
} }
dlIdx, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64) dlIdx, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64)
@ -662,7 +662,7 @@ var provingRecoverFaultsCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() < 1 { if cctx.NArg() < 1 {
return xerrors.Errorf("must pass at least 1 sector number") return lcli.ShowHelp(cctx, xerrors.Errorf("must pass at least 1 sector number"))
} }
arglist := cctx.Args().Slice() arglist := cctx.Args().Slice()

View File

@ -373,7 +373,7 @@ var sealingAbortCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return xerrors.Errorf("expected 1 argument") return lcli.IncorrectNumArgs(cctx)
} }
minerApi, closer, err := lcli.GetStorageMinerAPI(cctx) minerApi, closer, err := lcli.GetStorageMinerAPI(cctx)
@ -431,7 +431,7 @@ var sealingDataCidCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() < 1 || cctx.NArg() > 2 { if cctx.NArg() < 1 || cctx.NArg() > 2 {
return xerrors.Errorf("expected 1 or 2 arguments") return lcli.ShowHelp(cctx, xerrors.Errorf("expected 1 or 2 arguments"))
} }
minerApi, closer, err := lcli.GetStorageMinerAPI(cctx) minerApi, closer, err := lcli.GetStorageMinerAPI(cctx)

View File

@ -1379,7 +1379,7 @@ var sectorsTerminateCmd = &cli.Command{
defer closer() defer closer()
ctx := lcli.ReqContext(cctx) ctx := lcli.ReqContext(cctx)
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return xerrors.Errorf("must pass sector number") return lcli.IncorrectNumArgs(cctx)
} }
id, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64) id, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64)
@ -1489,7 +1489,7 @@ var sectorsRemoveCmd = &cli.Command{
defer closer() defer closer()
ctx := lcli.ReqContext(cctx) ctx := lcli.ReqContext(cctx)
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return xerrors.Errorf("must pass sector number") return lcli.IncorrectNumArgs(cctx)
} }
id, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64) id, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64)
@ -1507,7 +1507,7 @@ var sectorsSnapUpCmd = &cli.Command{
ArgsUsage: "<sectorNum>", ArgsUsage: "<sectorNum>",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return lcli.ShowHelp(cctx, xerrors.Errorf("must pass sector number")) return lcli.IncorrectNumArgs(cctx)
} }
minerAPI, closer, err := lcli.GetStorageMinerAPI(cctx) minerAPI, closer, err := lcli.GetStorageMinerAPI(cctx)
@ -1588,7 +1588,7 @@ var sectorsStartSealCmd = &cli.Command{
defer closer() defer closer()
ctx := lcli.ReqContext(cctx) ctx := lcli.ReqContext(cctx)
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return xerrors.Errorf("must pass sector number") return lcli.IncorrectNumArgs(cctx)
} }
id, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64) id, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64)
@ -1612,7 +1612,7 @@ var sectorsSealDelayCmd = &cli.Command{
defer closer() defer closer()
ctx := lcli.ReqContext(cctx) ctx := lcli.ReqContext(cctx)
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return xerrors.Errorf("must pass duration in minutes") return lcli.IncorrectNumArgs(cctx)
} }
hs, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64) hs, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64)
@ -1715,7 +1715,7 @@ var sectorsUpdateCmd = &cli.Command{
defer closer() defer closer()
ctx := lcli.ReqContext(cctx) ctx := lcli.ReqContext(cctx)
if cctx.NArg() < 2 { if cctx.NArg() < 2 {
return xerrors.Errorf("must pass sector number and new state") return lcli.ShowHelp(cctx, xerrors.Errorf("must pass sector number and new state"))
} }
id, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64) id, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64)
@ -2311,7 +2311,7 @@ var sectorsNumbersReserveCmd = &cli.Command{
ctx := lcli.ReqContext(cctx) ctx := lcli.ReqContext(cctx)
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return xerrors.Errorf("expected 2 arguments: [reservation name] [reserved ranges]") return lcli.IncorrectNumArgs(cctx)
} }
bf, err := strle.HumanRangesToBitField(cctx.Args().Get(1)) bf, err := strle.HumanRangesToBitField(cctx.Args().Get(1))
@ -2336,7 +2336,7 @@ var sectorsNumbersFreeCmd = &cli.Command{
ctx := lcli.ReqContext(cctx) ctx := lcli.ReqContext(cctx)
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return xerrors.Errorf("expected 1 argument: [reservation name]") return lcli.IncorrectNumArgs(cctx)
} }
return minerAPI.SectorNumFree(ctx, cctx.Args().First()) return minerAPI.SectorNumFree(ctx, cctx.Args().First())

View File

@ -192,7 +192,7 @@ var actorSetOwnerCmd = &cli.Command{
} }
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return fmt.Errorf("must pass new owner address and sender address") return lcli.IncorrectNumArgs(cctx)
} }
var maddr address.Address var maddr address.Address

View File

@ -56,7 +56,7 @@ var computeStateRangeCmd = &cli.Command{
ArgsUsage: "[START_TIPSET_REF] [END_TIPSET_REF]", ArgsUsage: "[START_TIPSET_REF] [END_TIPSET_REF]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return fmt.Errorf("expected two arguments: a start and an end tipset") return lcli.IncorrectNumArgs(cctx)
} }
api, closer, err := lcli.GetFullNodeAPI(cctx) api, closer, err := lcli.GetFullNodeAPI(cctx)

View File

@ -20,6 +20,7 @@ import (
"go.uber.org/multierr" "go.uber.org/multierr"
"golang.org/x/xerrors" "golang.org/x/xerrors"
lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/lotus/lib/backupds" "github.com/filecoin-project/lotus/lib/backupds"
"github.com/filecoin-project/lotus/node/repo" "github.com/filecoin-project/lotus/node/repo"
) )
@ -172,7 +173,7 @@ var datastoreBackupStatCmd = &cli.Command{
ArgsUsage: "[file]", ArgsUsage: "[file]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return xerrors.Errorf("expected 1 argument") return lcli.IncorrectNumArgs(cctx)
} }
f, err := os.Open(cctx.Args().First()) f, err := os.Open(cctx.Args().First())
@ -221,7 +222,7 @@ var datastoreBackupListCmd = &cli.Command{
ArgsUsage: "[file]", ArgsUsage: "[file]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return xerrors.Errorf("expected 1 argument") return lcli.IncorrectNumArgs(cctx)
} }
f, err := os.Open(cctx.Args().First()) f, err := os.Open(cctx.Args().First())
@ -308,7 +309,7 @@ var datastoreRewriteCmd = &cli.Command{
ArgsUsage: "source destination", ArgsUsage: "source destination",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return xerrors.Errorf("expected 2 arguments, got %d", cctx.NArg()) return lcli.IncorrectNumArgs(cctx)
} }
fromPath, err := homedir.Expand(cctx.Args().Get(0)) fromPath, err := homedir.Expand(cctx.Args().Get(0))
if err != nil { if err != nil {

View File

@ -31,7 +31,7 @@ var diffStateTrees = &cli.Command{
ctx := lcli.ReqContext(cctx) ctx := lcli.ReqContext(cctx)
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return xerrors.Errorf("expected two state-tree roots") return lcli.IncorrectNumArgs(cctx)
} }
argA := cctx.Args().Get(0) argA := cctx.Args().Get(0)

View File

@ -39,7 +39,7 @@ var exportCarCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return lcli.ShowHelp(cctx, fmt.Errorf("must specify file name and object")) return lcli.IncorrectNumArgs(cctx)
} }
outfile := cctx.Args().First() outfile := cctx.Args().First()

View File

@ -300,7 +300,7 @@ var ledgerNewAddressesCmd = &cli.Command{
ctx := lcli.ReqContext(cctx) ctx := lcli.ReqContext(cctx)
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return fmt.Errorf("must pass account index") return lcli.IncorrectNumArgs(cctx)
} }
index, err := strconv.ParseUint(cctx.Args().First(), 10, 32) index, err := strconv.ParseUint(cctx.Args().First(), 10, 32)

View File

@ -16,6 +16,7 @@ import (
"github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/vm" "github.com/filecoin-project/lotus/chain/vm"
lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/lotus/node/repo" "github.com/filecoin-project/lotus/node/repo"
"github.com/filecoin-project/lotus/storage/sealer/ffiwrapper" "github.com/filecoin-project/lotus/storage/sealer/ffiwrapper"
) )
@ -34,7 +35,7 @@ var migrationsCmd = &cli.Command{
ctx := context.TODO() ctx := context.TODO()
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return fmt.Errorf("must pass block cid") return lcli.IncorrectNumArgs(cctx)
} }
blkCid, err := cid.Decode(cctx.Args().First()) blkCid, err := cid.Decode(cctx.Args().First())

View File

@ -128,7 +128,7 @@ var mmApproveWithdrawBalance = &cli.Command{
ArgsUsage: "[amount txnId proposer]", ArgsUsage: "[amount txnId proposer]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 3 { if cctx.NArg() != 3 {
return fmt.Errorf("must pass amount, txn Id, and proposer address") return lcli.IncorrectNumArgs(cctx)
} }
api, closer, err := lcli.GetFullNodeAPI(cctx) api, closer, err := lcli.GetFullNodeAPI(cctx)
@ -287,7 +287,7 @@ var mmApproveChangeOwner = &cli.Command{
ArgsUsage: "[newOwner txnId proposer]", ArgsUsage: "[newOwner txnId proposer]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 3 { if cctx.NArg() != 3 {
return fmt.Errorf("must pass new owner address, txn Id, and proposer address") return lcli.IncorrectNumArgs(cctx)
} }
api, closer, err := lcli.GetFullNodeAPI(cctx) api, closer, err := lcli.GetFullNodeAPI(cctx)

View File

@ -20,6 +20,7 @@ import (
"github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/state"
"github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/lotus/node/repo" "github.com/filecoin-project/lotus/node/repo"
) )
@ -35,7 +36,7 @@ var minerPeeridCmd = &cli.Command{
ctx := context.TODO() ctx := context.TODO()
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return fmt.Errorf("must pass peer id and state root") return lcli.IncorrectNumArgs(cctx)
} }
pid, err := peer.Decode(cctx.Args().Get(0)) pid, err := peer.Decode(cctx.Args().Get(0))

View File

@ -136,7 +136,7 @@ var minerCreateCmd = &cli.Command{
ctx := lcli.ReqContext(cctx) ctx := lcli.ReqContext(cctx)
if cctx.NArg() != 4 { if cctx.NArg() != 4 {
return xerrors.Errorf("expected 4 args (sender owner worker sectorSize)") return lcli.IncorrectNumArgs(cctx)
} }
sender, err := address.NewFromString(cctx.Args().First()) sender, err := address.NewFromString(cctx.Args().First())
@ -274,7 +274,7 @@ var minerUnpackInfoCmd = &cli.Command{
ArgsUsage: "[allinfo.txt] [dir]", ArgsUsage: "[allinfo.txt] [dir]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return xerrors.Errorf("expected 2 args") return lcli.IncorrectNumArgs(cctx)
} }
src, err := homedir.Expand(cctx.Args().Get(0)) src, err := homedir.Expand(cctx.Args().Get(0))
@ -488,9 +488,10 @@ var generateAndSendConsensusFaultCmd = &cli.Command{
Name: "generate-and-send-consensus-fault", Name: "generate-and-send-consensus-fault",
Usage: "Provided a block CID mined by the miner, will create another block at the same height, and send both block headers to generate a consensus fault.", Usage: "Provided a block CID mined by the miner, will create another block at the same height, and send both block headers to generate a consensus fault.",
Description: `Note: This is meant for testing purposes and should NOT be used on mainnet or you will be slashed`, Description: `Note: This is meant for testing purposes and should NOT be used on mainnet or you will be slashed`,
ArgsUsage: "blockCID",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return xerrors.Errorf("expected 1 arg (blockCID)") return lcli.IncorrectNumArgs(cctx)
} }
blockCid, err := cid.Parse(cctx.Args().First()) blockCid, err := cid.Parse(cctx.Args().First())

View File

@ -28,7 +28,7 @@ var msgCmd = &cli.Command{
ArgsUsage: "Message in any form", ArgsUsage: "Message in any form",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return xerrors.Errorf("expected 1 argument") return lcli.IncorrectNumArgs(cctx)
} }
msg, err := messageFromString(cctx, cctx.Args().First()) msg, err := messageFromString(cctx, cctx.Args().First())

View File

@ -11,6 +11,8 @@ import (
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/abi"
prooftypes "github.com/filecoin-project/go-state-types/proof" prooftypes "github.com/filecoin-project/go-state-types/proof"
lcli "github.com/filecoin-project/lotus/cli"
) )
var proofsCmd = &cli.Command{ var proofsCmd = &cli.Command{
@ -43,7 +45,7 @@ var verifySealProofCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 3 { if cctx.NArg() != 3 {
return fmt.Errorf("must specify commR, commD, and proof to verify") return lcli.IncorrectNumArgs(cctx)
} }
commr, err := cid.Decode(cctx.Args().Get(0)) commr, err := cid.Decode(cctx.Args().Get(0))

View File

@ -113,7 +113,7 @@ var rpcCmd = &cli.Command{
if cctx.Args().Present() { if cctx.Args().Present() {
if cctx.NArg() > 2 { if cctx.NArg() > 2 {
return xerrors.Errorf("expected 1 or 2 arguments: method [params]") return lcli.ShowHelp(cctx, xerrors.Errorf("expected 1 or 2 arguments: method [params]"))
} }
params := cctx.Args().Get(1) params := cctx.Args().Get(1)

View File

@ -65,7 +65,7 @@ var terminateSectorCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() < 1 { if cctx.NArg() < 1 {
return fmt.Errorf("at least one sector must be specified") return lcli.ShowHelp(cctx, fmt.Errorf("at least one sector must be specified"))
} }
var maddr address.Address var maddr address.Address
@ -201,7 +201,7 @@ var terminateSectorPenaltyEstimationCmd = &cli.Command{
}, },
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() < 1 { if cctx.NArg() < 1 {
return fmt.Errorf("at least one sector must be specified") return lcli.ShowHelp(cctx, fmt.Errorf("at least one sector must be specified"))
} }
var maddr address.Address var maddr address.Address

View File

@ -34,7 +34,7 @@ var sendCsvCmd = &cli.Command{
ArgsUsage: "[csvfile]", ArgsUsage: "[csvfile]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return xerrors.New("must supply path to csv file") return lcli.IncorrectNumArgs(cctx)
} }
api, closer, err := lcli.GetFullNodeAPIV1(cctx) api, closer, err := lcli.GetFullNodeAPIV1(cctx)

View File

@ -32,7 +32,7 @@ var sigsVerifyBlsMsgsCmd = &cli.Command{
Usage: "<blockCid>", Usage: "<blockCid>",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return xerrors.Errorf("usage: <blockCid>") return lcli.IncorrectNumArgs(cctx)
} }
api, closer, err := lcli.GetFullNodeAPI(cctx) api, closer, err := lcli.GetFullNodeAPI(cctx)
@ -102,7 +102,7 @@ var sigsVerifyVoteCmd = &cli.Command{
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 3 { if cctx.NArg() != 3 {
return xerrors.Errorf("usage: verify-vote <FIPnumber> <signingAddress> <signature>") return lcli.IncorrectNumArgs(cctx)
} }
fip, err := strconv.ParseInt(cctx.Args().First(), 10, 64) fip, err := strconv.ParseInt(cctx.Args().First(), 10, 64)

View File

@ -39,9 +39,7 @@ var syncValidateCmd = &cli.Command{
ctx := lcli.ReqContext(cctx) ctx := lcli.ReqContext(cctx)
if cctx.NArg() < 1 { if cctx.NArg() < 1 {
fmt.Println("usage: <blockCid1> <blockCid2>...") return lcli.ShowHelp(cctx, fmt.Errorf("at least one block cid must be provided"))
fmt.Println("At least one block cid must be provided")
return nil
} }
args := cctx.Args().Slice() args := cctx.Args().Slice()
@ -91,9 +89,7 @@ var syncScrapePowerCmd = &cli.Command{
ctx := lcli.ReqContext(cctx) ctx := lcli.ReqContext(cctx)
if cctx.NArg() < 1 { if cctx.NArg() < 1 {
fmt.Println("usage: <blockCid1> <blockCid2>...") return lcli.ShowHelp(cctx, fmt.Errorf("at least one block cid must be provided"))
fmt.Println("At least one block cid must be provided")
return nil
} }
h, err := strconv.ParseInt(cctx.Args().Get(0), 10, 0) h, err := strconv.ParseInt(cctx.Args().Get(0), 10, 0)

View File

@ -23,6 +23,7 @@ import (
"github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/state"
"github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
lcli "github.com/filecoin-project/lotus/cli"
"github.com/filecoin-project/lotus/node/repo" "github.com/filecoin-project/lotus/node/repo"
) )
@ -40,7 +41,7 @@ var terminationsCmd = &cli.Command{
ctx := context.TODO() ctx := context.TODO()
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return fmt.Errorf("must pass block cid && lookback period") return lcli.IncorrectNumArgs(cctx)
} }
blkCid, err := cid.Decode(cctx.Args().First()) blkCid, err := cid.Decode(cctx.Args().First())

View File

@ -47,7 +47,7 @@ var verifRegAddVerifierFromMsigCmd = &cli.Command{
ArgsUsage: "<message sender> <new verifier> <allowance>", ArgsUsage: "<message sender> <new verifier> <allowance>",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 3 { if cctx.NArg() != 3 {
return fmt.Errorf("must specify three arguments: sender, verifier, and allowance") return lcli.IncorrectNumArgs(cctx)
} }
sender, err := address.NewFromString(cctx.Args().Get(0)) sender, err := address.NewFromString(cctx.Args().Get(0))
@ -120,7 +120,7 @@ var verifRegAddVerifierFromAccountCmd = &cli.Command{
ArgsUsage: "<verifier root key> <new verifier> <allowance>", ArgsUsage: "<verifier root key> <new verifier> <allowance>",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 3 { if cctx.NArg() != 3 {
return fmt.Errorf("must specify three arguments: sender, verifier, and allowance") return lcli.IncorrectNumArgs(cctx)
} }
sender, err := address.NewFromString(cctx.Args().Get(0)) sender, err := address.NewFromString(cctx.Args().Get(0))
@ -202,7 +202,7 @@ var verifRegVerifyClientCmd = &cli.Command{
} }
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return fmt.Errorf("must specify two arguments: address and allowance") return lcli.IncorrectNumArgs(cctx)
} }
target, err := address.NewFromString(cctx.Args().Get(0)) target, err := address.NewFromString(cctx.Args().Get(0))
@ -419,7 +419,7 @@ var verifRegRemoveVerifiedClientDataCapCmd = &cli.Command{
ArgsUsage: "<message sender> <client address> <allowance to remove> <verifier 1 address> <verifier 1 signature> <verifier 2 address> <verifier 2 signature>", ArgsUsage: "<message sender> <client address> <allowance to remove> <verifier 1 address> <verifier 1 signature> <verifier 2 address> <verifier 2 signature>",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 7 { if cctx.NArg() != 7 {
return fmt.Errorf("must specify seven arguments: sender, client, allowance to remove, verifier 1 address, verifier 1 signature, verifier 2 address, verifier 2 signature") return lcli.IncorrectNumArgs(cctx)
} }
srv, err := lcli.GetFullNodeServices(cctx) srv, err := lcli.GetFullNodeServices(cctx)