From 308cef950b3180fec651bccc31da2c21c96c6fc7 Mon Sep 17 00:00:00 2001 From: Geoff Stuart Date: Wed, 14 Sep 2022 14:33:29 -0400 Subject: [PATCH] cctx.Args().Len() to cctx.NArg() --- cli/backup.go | 2 +- cli/chain.go | 6 ++-- cli/client.go | 4 +-- cli/filplus.go | 4 +-- cli/mpool.go | 6 ++-- cli/multisig.go | 52 +++++++++++++++---------------- cli/net.go | 2 +- cli/paych.go | 22 ++++++------- cli/send.go | 2 +- cli/state.go | 8 ++--- cmd/lotus-bench/simple.go | 2 +- cmd/lotus-miner/init_restore.go | 2 +- cmd/lotus-miner/market.go | 4 +-- cmd/lotus-miner/proving.go | 8 ++--- cmd/lotus-miner/sealing.go | 6 ++-- cmd/lotus-miner/sectors.go | 18 +++++------ cmd/lotus-seed/genesis.go | 12 +++---- cmd/lotus-shed/base16.go | 2 +- cmd/lotus-shed/base32.go | 2 +- cmd/lotus-shed/base64.go | 2 +- cmd/lotus-shed/consensus.go | 2 +- cmd/lotus-shed/datastore.go | 4 +-- cmd/lotus-shed/export-car.go | 2 +- cmd/lotus-shed/keyinfo.go | 4 +-- cmd/lotus-shed/miner.go | 4 +-- cmd/lotus-shed/msg.go | 2 +- cmd/lotus-shed/proofs.go | 2 +- cmd/lotus-shed/rpc.go | 2 +- cmd/lotus-shed/sectors.go | 4 +-- cmd/lotus-shed/signatures.go | 4 +-- cmd/lotus-shed/stateroot-stats.go | 4 +-- cmd/lotus-shed/sync.go | 6 ++-- cmd/lotus-shed/verifreg.go | 8 ++--- 33 files changed, 107 insertions(+), 107 deletions(-) diff --git a/cli/backup.go b/cli/backup.go index 4d88d4bbc..3cb44718f 100644 --- a/cli/backup.go +++ b/cli/backup.go @@ -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") } diff --git a/cli/chain.go b/cli/chain.go index 39f1608f5..80df5655b 100644 --- a/cli/chain.go +++ b/cli/chain.go @@ -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")) } diff --git a/cli/client.go b/cli/client.go index 5f2342b2b..577a8e840 100644 --- a/cli/client.go +++ b/cli/client.go @@ -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 ") } @@ -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 ") } diff --git a/cli/filplus.go b/cli/filplus.go index 66de32d0c..7ac4f0d58 100644 --- a/cli/filplus.go +++ b/cli/filplus.go @@ -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") } diff --git a/cli/mpool.go b/cli/mpool.go index 1410814b5..c8003092d 100644 --- a/cli/mpool.go +++ b/cli/mpool.go @@ -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 diff --git a/cli/multisig.go b/cli/multisig.go index 67c833397..7a86c2d87 100644 --- a/cli/multisig.go +++ b/cli/multisig.go @@ -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 ")) } - if cctx.Args().Len() > 5 && cctx.Args().Len() != 7 { + if cctx.NArg() > 5 && cctx.NArg() != 7 { return ShowHelp(cctx, fmt.Errorf("usage: msig approve [ ]")) } @@ -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 ")) } - if cctx.Args().Len() > 4 && cctx.Args().Len() != 6 { + if cctx.NArg() > 4 && cctx.NArg() != 6 { return ShowHelp(cctx, fmt.Errorf("usage: msig cancel [ ]")) } @@ -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")) } diff --git a/cli/net.go b/cli/net.go index 5a141e52d..c1ca1ce18 100644 --- a/cli/net.go +++ b/cli/net.go @@ -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") } diff --git a/cli/paych.go b/cli/paych.go index 8277e3123..263aa7f34 100644 --- a/cli/paych.go +++ b/cli/paych.go @@ -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: ")) } @@ -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: ")) } 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: ")) } 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: ")) } @@ -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")) } diff --git a/cli/send.go b/cli/send.go index b5bfd3eb0..b2471e7cd 100644 --- a/cli/send.go +++ b/cli/send.go @@ -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")) } diff --git a/cli/state.go b/cli/state.go index bea7ed0df..e4afc6915 100644 --- a/cli/state.go +++ b/cli/state.go @@ -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") } diff --git a/cmd/lotus-bench/simple.go b/cmd/lotus-bench/simple.go index b999cd277..87e2c3bc0 100644 --- a/cmd/lotus-bench/simple.go +++ b/cmd/lotus-bench/simple.go @@ -959,7 +959,7 @@ var simpleProveReplicaUpdate2 = &cli.Command{ } func ParsePieceInfos(cctx *cli.Context, firstArg int) ([]abi.PieceInfo, error) { - args := cctx.Args().Len() - firstArg + args := cctx.NArg() - firstArg if args%2 != 0 { return nil, xerrors.Errorf("piece info argunemts need to be supplied in pairs") } diff --git a/cmd/lotus-miner/init_restore.go b/cmd/lotus-miner/init_restore.go index a54146fb2..9d7f977b6 100644 --- a/cmd/lotus-miner/init_restore.go +++ b/cmd/lotus-miner/init_restore.go @@ -96,7 +96,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 { - if cctx.Args().Len() != 1 { + if cctx.NArg() != 1 { return xerrors.Errorf("expected 1 argument") } diff --git a/cmd/lotus-miner/market.go b/cmd/lotus-miner/market.go index 37d252efa..78b68214e 100644 --- a/cmd/lotus-miner/market.go +++ b/cmd/lotus-miner/market.go @@ -370,7 +370,7 @@ var dealsImportDataCmd = &cli.Command{ ctx := lcli.DaemonContext(cctx) - if cctx.Args().Len() < 2 { + if cctx.NArg() < 2 { return fmt.Errorf("must specify proposal CID and file path") } @@ -617,7 +617,7 @@ var setSealDurationCmd = &cli.Command{ } defer closer() ctx := lcli.ReqContext(cctx) - if cctx.Args().Len() != 1 { + if cctx.NArg() != 1 { return xerrors.Errorf("must pass duration in minutes") } diff --git a/cmd/lotus-miner/proving.go b/cmd/lotus-miner/proving.go index 85bc48e78..bbb744680 100644 --- a/cmd/lotus-miner/proving.go +++ b/cmd/lotus-miner/proving.go @@ -314,7 +314,7 @@ var provingDeadlineInfoCmd = &cli.Command{ ArgsUsage: "", Action: func(cctx *cli.Context) error { - if cctx.Args().Len() != 1 { + if cctx.NArg() != 1 { return xerrors.Errorf("must pass deadline index") } @@ -461,7 +461,7 @@ var provingCheckProvableCmd = &cli.Command{ }, }, Action: func(cctx *cli.Context) error { - if cctx.Args().Len() != 1 { + if cctx.NArg() != 1 { return xerrors.Errorf("must pass deadline index") } @@ -616,7 +616,7 @@ var provingComputeWindowPoStCmd = &cli.Command{ It will not send any messages to the chain.`, ArgsUsage: "[deadline index]", Action: func(cctx *cli.Context) error { - if cctx.Args().Len() != 1 { + if cctx.NArg() != 1 { return xerrors.Errorf("must pass deadline index") } @@ -661,7 +661,7 @@ var provingRecoverFaultsCmd = &cli.Command{ }, }, Action: func(cctx *cli.Context) error { - if cctx.Args().Len() < 1 { + if cctx.NArg() < 1 { return xerrors.Errorf("must pass at least 1 sector number") } diff --git a/cmd/lotus-miner/sealing.go b/cmd/lotus-miner/sealing.go index 970f54a55..334266c79 100644 --- a/cmd/lotus-miner/sealing.go +++ b/cmd/lotus-miner/sealing.go @@ -372,7 +372,7 @@ var sealingAbortCmd = &cli.Command{ }, }, Action: func(cctx *cli.Context) error { - if cctx.Args().Len() != 1 { + if cctx.NArg() != 1 { return xerrors.Errorf("expected 1 argument") } @@ -430,7 +430,7 @@ var sealingDataCidCmd = &cli.Command{ }, }, Action: func(cctx *cli.Context) error { - if cctx.Args().Len() < 1 || cctx.Args().Len() > 2 { + if cctx.NArg() < 1 || cctx.NArg() > 2 { return xerrors.Errorf("expected 1 or 2 arguments") } @@ -484,7 +484,7 @@ var sealingDataCidCmd = &cli.Command{ } var psize abi.PaddedPieceSize - if cctx.Args().Len() == 2 { + if cctx.NArg() == 2 { rps, err := humanize.ParseBytes(cctx.Args().Get(1)) if err != nil { return xerrors.Errorf("parsing piece size: %w", err) diff --git a/cmd/lotus-miner/sectors.go b/cmd/lotus-miner/sectors.go index 45a1256aa..336a06f52 100644 --- a/cmd/lotus-miner/sectors.go +++ b/cmd/lotus-miner/sectors.go @@ -1378,7 +1378,7 @@ var sectorsTerminateCmd = &cli.Command{ } defer closer() ctx := lcli.ReqContext(cctx) - if cctx.Args().Len() != 1 { + if cctx.NArg() != 1 { return xerrors.Errorf("must pass sector number") } @@ -1488,7 +1488,7 @@ var sectorsRemoveCmd = &cli.Command{ } defer closer() ctx := lcli.ReqContext(cctx) - if cctx.Args().Len() != 1 { + if cctx.NArg() != 1 { return xerrors.Errorf("must pass sector number") } @@ -1506,7 +1506,7 @@ var sectorsSnapUpCmd = &cli.Command{ Usage: "Mark a committed capacity sector to be filled with deals", ArgsUsage: "", Action: func(cctx *cli.Context) error { - if cctx.Args().Len() != 1 { + if cctx.NArg() != 1 { return lcli.ShowHelp(cctx, xerrors.Errorf("must pass sector number")) } @@ -1550,7 +1550,7 @@ var sectorsSnapAbortCmd = &cli.Command{ }, }, Action: func(cctx *cli.Context) error { - if cctx.Args().Len() != 1 { + if cctx.NArg() != 1 { return lcli.ShowHelp(cctx, xerrors.Errorf("must pass sector number")) } @@ -1587,7 +1587,7 @@ var sectorsStartSealCmd = &cli.Command{ } defer closer() ctx := lcli.ReqContext(cctx) - if cctx.Args().Len() != 1 { + if cctx.NArg() != 1 { return xerrors.Errorf("must pass sector number") } @@ -1611,7 +1611,7 @@ var sectorsSealDelayCmd = &cli.Command{ } defer closer() ctx := lcli.ReqContext(cctx) - if cctx.Args().Len() != 1 { + if cctx.NArg() != 1 { return xerrors.Errorf("must pass duration in minutes") } @@ -1714,7 +1714,7 @@ var sectorsUpdateCmd = &cli.Command{ } defer closer() ctx := lcli.ReqContext(cctx) - if cctx.Args().Len() < 2 { + if cctx.NArg() < 2 { return xerrors.Errorf("must pass sector number and new state") } @@ -2310,7 +2310,7 @@ var sectorsNumbersReserveCmd = &cli.Command{ defer closer() ctx := lcli.ReqContext(cctx) - if cctx.Args().Len() != 2 { + if cctx.NArg() != 2 { return xerrors.Errorf("expected 2 arguments: [reservation name] [reserved ranges]") } @@ -2335,7 +2335,7 @@ var sectorsNumbersFreeCmd = &cli.Command{ defer closer() ctx := lcli.ReqContext(cctx) - if cctx.Args().Len() != 1 { + if cctx.NArg() != 1 { return xerrors.Errorf("expected 1 argument: [reservation name]") } diff --git a/cmd/lotus-seed/genesis.go b/cmd/lotus-seed/genesis.go index 9f0a8f7dc..df2a91ad9 100644 --- a/cmd/lotus-seed/genesis.go +++ b/cmd/lotus-seed/genesis.go @@ -93,7 +93,7 @@ var genesisAddMinerCmd = &cli.Command{ Description: "add genesis miner", Flags: []cli.Flag{}, Action: func(cctx *cli.Context) error { - if cctx.Args().Len() != 2 { + if cctx.NArg() != 2 { return xerrors.New("seed genesis add-miner [genesis.json] [preseal.json]") } @@ -181,7 +181,7 @@ type GenAccountEntry struct { var genesisAddMsigsCmd = &cli.Command{ Name: "add-msigs", Action: func(cctx *cli.Context) error { - if cctx.Args().Len() < 2 { + if cctx.NArg() < 2 { return fmt.Errorf("must specify template file and csv file with accounts") } @@ -329,7 +329,7 @@ var genesisSetVRKCmd = &cli.Command{ }, }, Action: func(cctx *cli.Context) error { - if cctx.Args().Len() != 1 { + if cctx.NArg() != 1 { return fmt.Errorf("must specify template file") } @@ -425,7 +425,7 @@ var genesisSetRemainderCmd = &cli.Command{ }, }, Action: func(cctx *cli.Context) error { - if cctx.Args().Len() != 1 { + if cctx.NArg() != 1 { return fmt.Errorf("must specify template file") } @@ -519,7 +519,7 @@ var genesisSetActorVersionCmd = &cli.Command{ }, ArgsUsage: "", Action: func(cctx *cli.Context) error { - if cctx.Args().Len() != 1 { + if cctx.NArg() != 1 { return fmt.Errorf("must specify genesis file") } @@ -597,7 +597,7 @@ var genesisSetVRKSignersCmd = &cli.Command{ }, }, Action: func(cctx *cli.Context) error { - if cctx.Args().Len() != 1 { + if cctx.NArg() != 1 { return fmt.Errorf("must specify template file") } diff --git a/cmd/lotus-shed/base16.go b/cmd/lotus-shed/base16.go index adfdfeddb..a5d384815 100644 --- a/cmd/lotus-shed/base16.go +++ b/cmd/lotus-shed/base16.go @@ -24,7 +24,7 @@ var base16Cmd = &cli.Command{ Action: func(cctx *cli.Context) error { var input io.Reader - if cctx.Args().Len() == 0 { + if cctx.NArg() == 0 { input = os.Stdin } else { input = strings.NewReader(cctx.Args().First()) diff --git a/cmd/lotus-shed/base32.go b/cmd/lotus-shed/base32.go index 4ca177316..66e180ddc 100644 --- a/cmd/lotus-shed/base32.go +++ b/cmd/lotus-shed/base32.go @@ -24,7 +24,7 @@ var base32Cmd = &cli.Command{ Action: func(cctx *cli.Context) error { var input io.Reader - if cctx.Args().Len() == 0 { + if cctx.NArg() == 0 { input = os.Stdin } else { input = strings.NewReader(cctx.Args().First()) diff --git a/cmd/lotus-shed/base64.go b/cmd/lotus-shed/base64.go index 9143a6a19..cacc60152 100644 --- a/cmd/lotus-shed/base64.go +++ b/cmd/lotus-shed/base64.go @@ -32,7 +32,7 @@ var base64Cmd = &cli.Command{ Action: func(cctx *cli.Context) error { var input io.Reader - if cctx.Args().Len() == 0 { + if cctx.NArg() == 0 { input = os.Stdin } else { input = strings.NewReader(cctx.Args().First()) diff --git a/cmd/lotus-shed/consensus.go b/cmd/lotus-shed/consensus.go index f6bd7688f..197de56f9 100644 --- a/cmd/lotus-shed/consensus.go +++ b/cmd/lotus-shed/consensus.go @@ -84,7 +84,7 @@ var consensusCheckCmd = &cli.Command{ filePath := cctx.Args().First() var input *bufio.Reader - if cctx.Args().Len() == 0 { + if cctx.NArg() == 0 { input = bufio.NewReader(os.Stdin) } else { var err error diff --git a/cmd/lotus-shed/datastore.go b/cmd/lotus-shed/datastore.go index 7cdb2b1e6..cd650d122 100644 --- a/cmd/lotus-shed/datastore.go +++ b/cmd/lotus-shed/datastore.go @@ -171,7 +171,7 @@ var datastoreBackupStatCmd = &cli.Command{ Description: "validate and print info about datastore backup", ArgsUsage: "[file]", Action: func(cctx *cli.Context) error { - if cctx.Args().Len() != 1 { + if cctx.NArg() != 1 { return xerrors.Errorf("expected 1 argument") } @@ -220,7 +220,7 @@ var datastoreBackupListCmd = &cli.Command{ }, ArgsUsage: "[file]", Action: func(cctx *cli.Context) error { - if cctx.Args().Len() != 1 { + if cctx.NArg() != 1 { return xerrors.Errorf("expected 1 argument") } diff --git a/cmd/lotus-shed/export-car.go b/cmd/lotus-shed/export-car.go index 97e4fb6c6..b33b2b4ec 100644 --- a/cmd/lotus-shed/export-car.go +++ b/cmd/lotus-shed/export-car.go @@ -38,7 +38,7 @@ var exportCarCmd = &cli.Command{ }, }, Action: func(cctx *cli.Context) error { - if cctx.Args().Len() != 2 { + if cctx.NArg() != 2 { return lcli.ShowHelp(cctx, fmt.Errorf("must specify file name and object")) } diff --git a/cmd/lotus-shed/keyinfo.go b/cmd/lotus-shed/keyinfo.go index 135b5bc9d..373964dc6 100644 --- a/cmd/lotus-shed/keyinfo.go +++ b/cmd/lotus-shed/keyinfo.go @@ -149,7 +149,7 @@ var keyinfoImportCmd = &cli.Command{ flagRepo := cctx.String("repo") var input io.Reader - if cctx.Args().Len() == 0 { + if cctx.NArg() == 0 { input = os.Stdin } else { var err error @@ -261,7 +261,7 @@ var keyinfoInfoCmd = &cli.Command{ format := cctx.String("format") var input io.Reader - if cctx.Args().Len() == 0 { + if cctx.NArg() == 0 { input = os.Stdin } else { var err error diff --git a/cmd/lotus-shed/miner.go b/cmd/lotus-shed/miner.go index a23a44410..0d925336d 100644 --- a/cmd/lotus-shed/miner.go +++ b/cmd/lotus-shed/miner.go @@ -135,7 +135,7 @@ var minerCreateCmd = &cli.Command{ defer closer() ctx := lcli.ReqContext(cctx) - if cctx.Args().Len() != 4 { + if cctx.NArg() != 4 { return xerrors.Errorf("expected 4 args (sender owner worker sectorSize)") } @@ -273,7 +273,7 @@ var minerUnpackInfoCmd = &cli.Command{ Usage: "unpack miner info all dump", ArgsUsage: "[allinfo.txt] [dir]", Action: func(cctx *cli.Context) error { - if cctx.Args().Len() != 2 { + if cctx.NArg() != 2 { return xerrors.Errorf("expected 2 args") } diff --git a/cmd/lotus-shed/msg.go b/cmd/lotus-shed/msg.go index 49412948c..34b260961 100644 --- a/cmd/lotus-shed/msg.go +++ b/cmd/lotus-shed/msg.go @@ -27,7 +27,7 @@ var msgCmd = &cli.Command{ Usage: "Translate message between various formats", ArgsUsage: "Message in any form", Action: func(cctx *cli.Context) error { - if cctx.Args().Len() != 1 { + if cctx.NArg() != 1 { return xerrors.Errorf("expected 1 argument") } diff --git a/cmd/lotus-shed/proofs.go b/cmd/lotus-shed/proofs.go index 65cf04918..752469778 100644 --- a/cmd/lotus-shed/proofs.go +++ b/cmd/lotus-shed/proofs.go @@ -42,7 +42,7 @@ var verifySealProofCmd = &cli.Command{ }, }, Action: func(cctx *cli.Context) error { - if cctx.Args().Len() != 3 { + if cctx.NArg() != 3 { return fmt.Errorf("must specify commR, commD, and proof to verify") } diff --git a/cmd/lotus-shed/rpc.go b/cmd/lotus-shed/rpc.go index b253304a1..82412e317 100644 --- a/cmd/lotus-shed/rpc.go +++ b/cmd/lotus-shed/rpc.go @@ -112,7 +112,7 @@ var rpcCmd = &cli.Command{ } if cctx.Args().Present() { - if cctx.Args().Len() > 2 { + if cctx.NArg() > 2 { return xerrors.Errorf("expected 1 or 2 arguments: method [params]") } diff --git a/cmd/lotus-shed/sectors.go b/cmd/lotus-shed/sectors.go index 0332b4ba3..39e17f045 100644 --- a/cmd/lotus-shed/sectors.go +++ b/cmd/lotus-shed/sectors.go @@ -64,7 +64,7 @@ var terminateSectorCmd = &cli.Command{ }, }, Action: func(cctx *cli.Context) error { - if cctx.Args().Len() < 1 { + if cctx.NArg() < 1 { return fmt.Errorf("at least one sector must be specified") } @@ -200,7 +200,7 @@ var terminateSectorPenaltyEstimationCmd = &cli.Command{ }, }, Action: func(cctx *cli.Context) error { - if cctx.Args().Len() < 1 { + if cctx.NArg() < 1 { return fmt.Errorf("at least one sector must be specified") } diff --git a/cmd/lotus-shed/signatures.go b/cmd/lotus-shed/signatures.go index 0f43503f6..d06ae56ea 100644 --- a/cmd/lotus-shed/signatures.go +++ b/cmd/lotus-shed/signatures.go @@ -31,7 +31,7 @@ var sigsVerifyBlsMsgsCmd = &cli.Command{ Description: "given a block, verifies the bls signature of the messages in the block", Usage: "", Action: func(cctx *cli.Context) error { - if cctx.Args().Len() != 1 { + if cctx.NArg() != 1 { return xerrors.Errorf("usage: ") } @@ -101,7 +101,7 @@ var sigsVerifyVoteCmd = &cli.Command{ Usage: " ", Action: func(cctx *cli.Context) error { - if cctx.Args().Len() != 3 { + if cctx.NArg() != 3 { return xerrors.Errorf("usage: verify-vote ") } diff --git a/cmd/lotus-shed/stateroot-stats.go b/cmd/lotus-shed/stateroot-stats.go index 7937b3ccd..f429c4e64 100644 --- a/cmd/lotus-shed/stateroot-stats.go +++ b/cmd/lotus-shed/stateroot-stats.go @@ -174,8 +174,8 @@ var staterootStatCmd = &cli.Command{ } outcap := 10 - if cctx.Args().Len() > outcap { - outcap = cctx.Args().Len() + if cctx.NArg() > outcap { + outcap = cctx.NArg() } if len(infos) < outcap { outcap = len(infos) diff --git a/cmd/lotus-shed/sync.go b/cmd/lotus-shed/sync.go index 397e76da3..915ef38d0 100644 --- a/cmd/lotus-shed/sync.go +++ b/cmd/lotus-shed/sync.go @@ -38,7 +38,7 @@ var syncValidateCmd = &cli.Command{ defer closer() ctx := lcli.ReqContext(cctx) - if cctx.Args().Len() < 1 { + if cctx.NArg() < 1 { fmt.Println("usage: ...") fmt.Println("At least one block cid must be provided") return nil @@ -75,7 +75,7 @@ var syncScrapePowerCmd = &cli.Command{ Usage: "given a height and a tipset, reports what percentage of mining power had a winning ticket between the tipset and height", ArgsUsage: "[height tipsetkey]", Action: func(cctx *cli.Context) error { - if cctx.Args().Len() < 1 { + if cctx.NArg() < 1 { fmt.Println("usage: [blockCid1 blockCid2...]") fmt.Println("Any CIDs passed after the height will be used as the tipset key") fmt.Println("If no block CIDs are provided, chain head will be used") @@ -90,7 +90,7 @@ var syncScrapePowerCmd = &cli.Command{ defer closer() ctx := lcli.ReqContext(cctx) - if cctx.Args().Len() < 1 { + if cctx.NArg() < 1 { fmt.Println("usage: ...") fmt.Println("At least one block cid must be provided") return nil diff --git a/cmd/lotus-shed/verifreg.go b/cmd/lotus-shed/verifreg.go index 2731ea11b..97392b2f0 100644 --- a/cmd/lotus-shed/verifreg.go +++ b/cmd/lotus-shed/verifreg.go @@ -46,7 +46,7 @@ var verifRegAddVerifierFromMsigCmd = &cli.Command{ Usage: "make a given account a verifier", ArgsUsage: " ", Action: func(cctx *cli.Context) error { - if cctx.Args().Len() != 3 { + if cctx.NArg() != 3 { return fmt.Errorf("must specify three arguments: sender, verifier, and allowance") } @@ -119,7 +119,7 @@ var verifRegAddVerifierFromAccountCmd = &cli.Command{ Usage: "make a given account a verifier", ArgsUsage: " ", Action: func(cctx *cli.Context) error { - if cctx.Args().Len() != 3 { + if cctx.NArg() != 3 { return fmt.Errorf("must specify three arguments: sender, verifier, and allowance") } @@ -201,7 +201,7 @@ var verifRegVerifyClientCmd = &cli.Command{ return err } - if cctx.Args().Len() != 2 { + if cctx.NArg() != 2 { return fmt.Errorf("must specify two arguments: address and allowance") } @@ -418,7 +418,7 @@ var verifRegRemoveVerifiedClientDataCapCmd = &cli.Command{ Usage: "Remove data cap from verified client", ArgsUsage: " ", Action: func(cctx *cli.Context) error { - if cctx.Args().Len() != 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") }