cctx.Args().Len() to cctx.NArg()

This commit is contained in:
Geoff Stuart
2022-09-14 14:33:29 -04:00
parent f567db64b6
commit 308cef950b
33 changed files with 107 additions and 107 deletions
+1 -1
View File
@@ -114,7 +114,7 @@ this command must be within this base path`,
},
ArgsUsage: "[backup file path]",
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 1 {
if cctx.NArg() != 1 {
return xerrors.Errorf("expected 1 argument")
}
+3 -3
View File
@@ -946,7 +946,7 @@ var ChainBisectCmd = &cli.Command{
defer closer()
ctx := ReqContext(cctx)
if cctx.Args().Len() < 4 {
if cctx.NArg() < 4 {
return xerrors.New("need at least 4 args")
}
@@ -1312,7 +1312,7 @@ var chainDecodeParamsCmd = &cli.Command{
defer closer()
ctx := ReqContext(cctx)
if cctx.Args().Len() != 3 {
if cctx.NArg() != 3 {
return ShowHelp(cctx, fmt.Errorf("incorrect number of arguments"))
}
@@ -1391,7 +1391,7 @@ var chainEncodeParamsCmd = &cli.Command{
Action: func(cctx *cli.Context) error {
afmt := NewAppFmt(cctx.App)
if cctx.Args().Len() != 3 {
if cctx.NArg() != 3 {
return ShowHelp(cctx, fmt.Errorf("incorrect number of arguments"))
}
+2 -2
View File
@@ -212,7 +212,7 @@ var clientCommPCmd = &cli.Command{
defer closer()
ctx := ReqContext(cctx)
if cctx.Args().Len() != 1 {
if cctx.NArg() != 1 {
return fmt.Errorf("usage: commP <inputPath>")
}
@@ -245,7 +245,7 @@ var clientCarGenCmd = &cli.Command{
defer closer()
ctx := ReqContext(cctx)
if cctx.Args().Len() != 2 {
if cctx.NArg() != 2 {
return fmt.Errorf("usage: generate-car <inputPath> <outputPath>")
}
+2 -2
View File
@@ -61,7 +61,7 @@ var filplusVerifyClientCmd = &cli.Command{
return err
}
if cctx.Args().Len() != 2 {
if cctx.NArg() != 2 {
return fmt.Errorf("must specify two arguments: address and allowance")
}
@@ -289,7 +289,7 @@ var filplusSignRemoveDataCapProposal = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 3 {
if cctx.NArg() != 3 {
return fmt.Errorf("must specify three arguments: notary address, client address, and allowance to remove")
}
+3 -3
View File
@@ -404,7 +404,7 @@ var MpoolReplaceCmd = &cli.Command{
var from address.Address
var nonce uint64
switch cctx.Args().Len() {
switch cctx.NArg() {
case 1:
mcid, err := cid.Decode(cctx.Args().First())
if err != nil {
@@ -610,7 +610,7 @@ var MpoolConfig = &cli.Command{
Usage: "get or set current mpool configuration",
ArgsUsage: "[new-config]",
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() > 1 {
if cctx.NArg() > 1 {
return cli.ShowCommandHelp(cctx, cctx.Command.Name)
}
@@ -624,7 +624,7 @@ var MpoolConfig = &cli.Command{
ctx := ReqContext(cctx)
if cctx.Args().Len() == 0 {
if cctx.NArg() == 0 {
cfg, err := api.MpoolGetConfig(ctx)
if err != nil {
return err
+26 -26
View File
@@ -88,7 +88,7 @@ var msigCreateCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() < 1 {
if cctx.NArg() < 1 {
return ShowHelp(cctx, fmt.Errorf("multisigs must have at least one signer"))
}
@@ -365,11 +365,11 @@ var msigProposeCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() < 3 {
if cctx.NArg() < 3 {
return ShowHelp(cctx, fmt.Errorf("must pass at least multisig address, destination, and value"))
}
if cctx.Args().Len() > 3 && cctx.Args().Len() != 5 {
if cctx.NArg() > 3 && cctx.NArg() != 5 {
return ShowHelp(cctx, fmt.Errorf("must either pass three or five arguments"))
}
@@ -399,7 +399,7 @@ var msigProposeCmd = &cli.Command{
var method uint64
var params []byte
if cctx.Args().Len() == 5 {
if cctx.NArg() == 5 {
m, err := strconv.ParseUint(cctx.Args().Get(3), 10, 64)
if err != nil {
return err
@@ -487,15 +487,15 @@ var msigApproveCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() < 2 {
if cctx.NArg() < 2 {
return ShowHelp(cctx, fmt.Errorf("must pass at least multisig address and message ID"))
}
if cctx.Args().Len() > 2 && cctx.Args().Len() < 5 {
if cctx.NArg() > 2 && cctx.NArg() < 5 {
return ShowHelp(cctx, fmt.Errorf("usage: msig approve <msig addr> <message ID> <proposer address> <desination> <value>"))
}
if cctx.Args().Len() > 5 && cctx.Args().Len() != 7 {
if cctx.NArg() > 5 && cctx.NArg() != 7 {
return ShowHelp(cctx, fmt.Errorf("usage: msig approve <msig addr> <message ID> <proposer address> <desination> <value> [ <method> <params> ]"))
}
@@ -534,7 +534,7 @@ var msigApproveCmd = &cli.Command{
}
var msgCid cid.Cid
if cctx.Args().Len() == 2 {
if cctx.NArg() == 2 {
proto, err := api.MsigApprove(ctx, msig, txid, from)
if err != nil {
return err
@@ -571,7 +571,7 @@ var msigApproveCmd = &cli.Command{
var method uint64
var params []byte
if cctx.Args().Len() == 7 {
if cctx.NArg() == 7 {
m, err := strconv.ParseUint(cctx.Args().Get(5), 10, 64)
if err != nil {
return err
@@ -624,15 +624,15 @@ var msigCancelCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() < 2 {
if cctx.NArg() < 2 {
return ShowHelp(cctx, fmt.Errorf("must pass at least multisig address and message ID"))
}
if cctx.Args().Len() > 2 && cctx.Args().Len() < 4 {
if cctx.NArg() > 2 && cctx.NArg() < 4 {
return ShowHelp(cctx, fmt.Errorf("usage: msig cancel <msig addr> <message ID> <desination> <value>"))
}
if cctx.Args().Len() > 4 && cctx.Args().Len() != 6 {
if cctx.NArg() > 4 && cctx.NArg() != 6 {
return ShowHelp(cctx, fmt.Errorf("usage: msig cancel <msig addr> <message ID> <desination> <value> [ <method> <params> ]"))
}
@@ -671,7 +671,7 @@ var msigCancelCmd = &cli.Command{
}
var msgCid cid.Cid
if cctx.Args().Len() == 2 {
if cctx.NArg() == 2 {
proto, err := api.MsigCancel(ctx, msig, txid, from)
if err != nil {
return err
@@ -696,7 +696,7 @@ var msigCancelCmd = &cli.Command{
var method uint64
var params []byte
if cctx.Args().Len() == 6 {
if cctx.NArg() == 6 {
m, err := strconv.ParseUint(cctx.Args().Get(4), 10, 64)
if err != nil {
return err
@@ -753,7 +753,7 @@ var msigRemoveProposeCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 2 {
if cctx.NArg() != 2 {
return ShowHelp(cctx, fmt.Errorf("must pass multisig address and signer address"))
}
@@ -840,7 +840,7 @@ var msigAddProposeCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 2 {
if cctx.NArg() != 2 {
return ShowHelp(cctx, fmt.Errorf("must pass multisig address and signer address"))
}
@@ -949,7 +949,7 @@ var msigAddApproveCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 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"))
}
@@ -1040,7 +1040,7 @@ var msigAddCancelCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 4 {
if cctx.NArg() != 4 {
return ShowHelp(cctx, fmt.Errorf("must pass multisig address, transaction id, new signer address, whether to increase threshold"))
}
@@ -1126,7 +1126,7 @@ var msigSwapProposeCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 3 {
if cctx.NArg() != 3 {
return ShowHelp(cctx, fmt.Errorf("must pass multisig address, old signer address, new signer address"))
}
@@ -1207,7 +1207,7 @@ var msigSwapApproveCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 5 {
if cctx.NArg() != 5 {
return ShowHelp(cctx, fmt.Errorf("must pass multisig address, proposer address, transaction id, old signer address, new signer address"))
}
@@ -1298,7 +1298,7 @@ var msigSwapCancelCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 4 {
if cctx.NArg() != 4 {
return ShowHelp(cctx, fmt.Errorf("must pass multisig address, transaction id, old signer address, new signer address"))
}
@@ -1384,7 +1384,7 @@ var msigLockProposeCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 4 {
if cctx.NArg() != 4 {
return ShowHelp(cctx, fmt.Errorf("must pass multisig address, start epoch, unlock duration, and amount"))
}
@@ -1480,7 +1480,7 @@ var msigLockApproveCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 6 {
if cctx.NArg() != 6 {
return ShowHelp(cctx, fmt.Errorf("must pass multisig address, proposer address, tx id, start epoch, unlock duration, and amount"))
}
@@ -1586,7 +1586,7 @@ var msigLockCancelCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 5 {
if cctx.NArg() != 5 {
return ShowHelp(cctx, fmt.Errorf("must pass multisig address, tx id, start epoch, unlock duration, and amount"))
}
@@ -1693,7 +1693,7 @@ var msigVestedCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 1 {
if cctx.NArg() != 1 {
return ShowHelp(cctx, fmt.Errorf("must pass multisig address"))
}
@@ -1749,7 +1749,7 @@ var msigProposeThresholdCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 2 {
if cctx.NArg() != 2 {
return ShowHelp(cctx, fmt.Errorf("must pass multisig address and new threshold value"))
}
+1 -1
View File
@@ -141,7 +141,7 @@ var NetPing = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 1 {
if cctx.NArg() != 1 {
return xerrors.Errorf("please provide a peerID")
}
+11 -11
View File
@@ -50,7 +50,7 @@ var paychAddFundsCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 3 {
if cctx.NArg() != 3 {
return ShowHelp(cctx, fmt.Errorf("must pass three arguments: <from> <to> <available funds>"))
}
@@ -112,7 +112,7 @@ var paychStatusByFromToCmd = &cli.Command{
Usage: "Show the status of an active outbound payment channel by from/to addresses",
ArgsUsage: "[fromAddress toAddress]",
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 2 {
if cctx.NArg() != 2 {
return ShowHelp(cctx, fmt.Errorf("must pass two arguments: <from address> <to address>"))
}
ctx := ReqContext(cctx)
@@ -148,7 +148,7 @@ var paychStatusCmd = &cli.Command{
Usage: "Show the status of an outbound payment channel",
ArgsUsage: "[channelAddress]",
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 1 {
if cctx.NArg() != 1 {
return ShowHelp(cctx, fmt.Errorf("must pass an argument: <channel address>"))
}
ctx := ReqContext(cctx)
@@ -260,7 +260,7 @@ var paychSettleCmd = &cli.Command{
Usage: "Settle a payment channel",
ArgsUsage: "[channelAddress]",
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 1 {
if cctx.NArg() != 1 {
return fmt.Errorf("must pass payment channel address")
}
@@ -300,7 +300,7 @@ var paychCloseCmd = &cli.Command{
Usage: "Collect funds for a payment channel",
ArgsUsage: "[channelAddress]",
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 1 {
if cctx.NArg() != 1 {
return fmt.Errorf("must pass payment channel address")
}
@@ -360,7 +360,7 @@ var paychVoucherCreateCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 2 {
if cctx.NArg() != 2 {
return ShowHelp(cctx, fmt.Errorf("must pass two arguments: <channel> <amount>"))
}
@@ -408,7 +408,7 @@ var paychVoucherCheckCmd = &cli.Command{
Usage: "Check validity of payment channel voucher",
ArgsUsage: "[channelAddress voucher]",
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 2 {
if cctx.NArg() != 2 {
return ShowHelp(cctx, fmt.Errorf("must pass payment channel address and voucher to validate"))
}
@@ -444,7 +444,7 @@ var paychVoucherAddCmd = &cli.Command{
Usage: "Add payment channel voucher to local datastore",
ArgsUsage: "[channelAddress voucher]",
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 2 {
if cctx.NArg() != 2 {
return ShowHelp(cctx, fmt.Errorf("must pass payment channel address and voucher"))
}
@@ -486,7 +486,7 @@ var paychVoucherListCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 1 {
if cctx.NArg() != 1 {
return ShowHelp(cctx, fmt.Errorf("must pass payment channel address"))
}
@@ -531,7 +531,7 @@ var paychVoucherBestSpendableCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 1 {
if cctx.NArg() != 1 {
return ShowHelp(cctx, fmt.Errorf("must pass payment channel address"))
}
@@ -602,7 +602,7 @@ var paychVoucherSubmitCmd = &cli.Command{
Usage: "Submit voucher to chain to update payment channel state",
ArgsUsage: "[channelAddress voucher]",
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 2 {
if cctx.NArg() != 2 {
return ShowHelp(cctx, fmt.Errorf("must pass payment channel address and voucher"))
}
+1 -1
View File
@@ -67,7 +67,7 @@ var sendCmd = &cli.Command{
fmt.Println("'force' flag is deprecated, use global flag 'force-send'")
}
if cctx.Args().Len() != 2 {
if cctx.NArg() != 2 {
return ShowHelp(cctx, fmt.Errorf("'send' expects two arguments, target and amount"))
}
+4 -4
View File
@@ -504,7 +504,7 @@ var StateReplayCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 1 {
if cctx.NArg() != 1 {
fmt.Println("must provide cid of message to replay")
return nil
}
@@ -1580,7 +1580,7 @@ var StateCallCmd = &cli.Command{
},
},
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() < 2 {
if cctx.NArg() < 2 {
return fmt.Errorf("must specify at least actor and method to invoke")
}
@@ -1619,7 +1619,7 @@ var StateCallCmd = &cli.Command{
var params []byte
// If params were passed in, decode them
if cctx.Args().Len() > 2 {
if cctx.NArg() > 2 {
switch cctx.String("encoding") {
case "base64":
params, err = base64.StdEncoding.DecodeString(cctx.Args().Get(2))
@@ -1743,7 +1743,7 @@ var StateSectorCmd = &cli.Command{
ctx := ReqContext(cctx)
if cctx.Args().Len() != 2 {
if cctx.NArg() != 2 {
return xerrors.Errorf("expected 2 params: minerAddress and sectorNumber")
}