diff --git a/cmd/lotus-miner/actor.go b/cmd/lotus-miner/actor.go index 7b01fc85b..bec2202b4 100644 --- a/cmd/lotus-miner/actor.go +++ b/cmd/lotus-miner/actor.go @@ -55,9 +55,10 @@ var actorCmd = &cli.Command{ } var actorSetAddrsCmd = &cli.Command{ - Name: "set-addresses", - Aliases: []string{"set-addrs"}, - Usage: "set addresses that your miner can be publicly dialed on", + Name: "set-addresses", + Aliases: []string{"set-addrs"}, + Usage: "set addresses that your miner can be publicly dialed on", + ArgsUsage: "", Flags: []cli.Flag{ &cli.StringFlag{ Name: "from", @@ -170,8 +171,9 @@ var actorSetAddrsCmd = &cli.Command{ } var actorSetPeeridCmd = &cli.Command{ - Name: "set-peer-id", - Usage: "set the peer id of your miner", + Name: "set-peer-id", + Usage: "set the peer id of your miner", + ArgsUsage: "", Flags: []cli.Flag{ &cli.Int64Flag{ Name: "gas-limit", @@ -194,6 +196,10 @@ var actorSetPeeridCmd = &cli.Command{ ctx := lcli.ReqContext(cctx) + if cctx.NArg() != 1 { + return lcli.IncorrectNumArgs(cctx) + } + pid, err := peer.Decode(cctx.Args().Get(0)) if err != nil { return fmt.Errorf("failed to parse input as a peerId: %w", err) @@ -720,15 +726,15 @@ var actorSetOwnerCmd = &cli.Command{ }, }, Action: func(cctx *cli.Context) error { + if cctx.NArg() != 2 { + return lcli.IncorrectNumArgs(cctx) + } + if !cctx.Bool("really-do-it") { fmt.Println("Pass --really-do-it to actually execute this action") return nil } - if cctx.NArg() != 2 { - return lcli.IncorrectNumArgs(cctx) - } - api, acloser, err := lcli.GetFullNodeAPI(cctx) if err != nil { return err diff --git a/cmd/lotus-miner/sectors.go b/cmd/lotus-miner/sectors.go index cb9f5a1a8..1473262c4 100644 --- a/cmd/lotus-miner/sectors.go +++ b/cmd/lotus-miner/sectors.go @@ -120,8 +120,8 @@ var sectorsStatusCmd = &cli.Command{ defer closer() ctx := lcli.ReqContext(cctx) - if !cctx.Args().Present() { - return fmt.Errorf("must specify sector number to get status of") + if cctx.NArg() != 1 { + return lcli.IncorrectNumArgs(cctx) } id, err := strconv.ParseUint(cctx.Args().First(), 10, 64) @@ -1145,9 +1145,6 @@ var sectorsTerminateCmd = &cli.Command{ sectorsTerminatePendingCmd, }, Action: func(cctx *cli.Context) error { - if !cctx.Bool("really-do-it") { - return xerrors.Errorf("pass --really-do-it to confirm this action") - } minerApi, closer, err := lcli.GetStorageMinerAPI(cctx) if err != nil { return err @@ -1158,6 +1155,10 @@ var sectorsTerminateCmd = &cli.Command{ return lcli.IncorrectNumArgs(cctx) } + if !cctx.Bool("really-do-it") { + return xerrors.Errorf("pass --really-do-it to confirm this action") + } + id, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64) if err != nil { return xerrors.Errorf("could not parse sector number: %w", err) @@ -1490,8 +1491,8 @@ var sectorsUpdateCmd = &cli.Command{ } defer closer() ctx := lcli.ReqContext(cctx) - if cctx.NArg() < 2 { - return lcli.ShowHelp(cctx, xerrors.Errorf("must pass sector number and new state")) + if cctx.NArg() != 2 { + return lcli.IncorrectNumArgs(cctx) } id, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64) diff --git a/cmd/lotus-miner/storage.go b/cmd/lotus-miner/storage.go index 5a9107223..a5aa354f8 100644 --- a/cmd/lotus-miner/storage.go +++ b/cmd/lotus-miner/storage.go @@ -55,8 +55,9 @@ stored while moving through the sealing pipeline (references as 'seal').`, } var storageAttachCmd = &cli.Command{ - Name: "attach", - Usage: "attach local storage path", + Name: "attach", + Usage: "attach local storage path", + ArgsUsage: "[path]", Description: `Storage can be attached to the miner using this command. The storage volume list is stored local to the miner in $LOTUS_MINER_PATH/storage.json. We do not recommend manually modifying this value without further understanding of the @@ -115,8 +116,8 @@ over time defer closer() ctx := lcli.ReqContext(cctx) - if !cctx.Args().Present() { - return xerrors.Errorf("must specify storage path to attach") + if cctx.NArg() != 1 { + return lcli.IncorrectNumArgs(cctx) } p, err := homedir.Expand(cctx.Args().First()) @@ -192,8 +193,8 @@ var storageDetachCmd = &cli.Command{ defer closer() ctx := lcli.ReqContext(cctx) - if !cctx.Args().Present() { - return xerrors.Errorf("must specify storage path") + if cctx.NArg() != 1 { + return lcli.IncorrectNumArgs(cctx) } p, err := homedir.Expand(cctx.Args().First()) @@ -210,8 +211,9 @@ var storageDetachCmd = &cli.Command{ } var storageRedeclareCmd = &cli.Command{ - Name: "redeclare", - Usage: "redeclare sectors in a local storage path", + Name: "redeclare", + Usage: "redeclare sectors in a local storage path", + ArgsUsage: "[path]", Flags: []cli.Flag{ &cli.StringFlag{ Name: "id", @@ -234,6 +236,10 @@ var storageRedeclareCmd = &cli.Command{ defer closer() ctx := lcli.ReqContext(cctx) + if cctx.NArg() != 1 { + return lcli.IncorrectNumArgs(cctx) + } + if cctx.IsSet("id") && cctx.Bool("all") { return xerrors.Errorf("--id and --all can't be passed at the same time") } @@ -466,6 +472,10 @@ var storageFindCmd = &cli.Command{ defer closer() ctx := lcli.ReqContext(cctx) + if cctx.NArg() != 1 { + return lcli.IncorrectNumArgs(cctx) + } + ma, err := minerApi.ActorAddress(ctx) if err != nil { return err diff --git a/documentation/en/cli-lotus-miner.md b/documentation/en/cli-lotus-miner.md index c5887c5be..4b8e42cc3 100644 --- a/documentation/en/cli-lotus-miner.md +++ b/documentation/en/cli-lotus-miner.md @@ -286,7 +286,7 @@ NAME: lotus-miner actor set-peer-id - set the peer id of your miner USAGE: - lotus-miner actor set-peer-id [command options] [arguments...] + lotus-miner actor set-peer-id [command options] OPTIONS: --gas-limit value set gas limit (default: 0) @@ -2273,7 +2273,7 @@ NAME: lotus-miner storage attach - attach local storage path USAGE: - lotus-miner storage attach [command options] [arguments...] + lotus-miner storage attach [command options] [path] DESCRIPTION: Storage can be attached to the miner using this command. The storage volume @@ -2326,7 +2326,7 @@ NAME: lotus-miner storage redeclare - redeclare sectors in a local storage path USAGE: - lotus-miner storage redeclare [command options] [arguments...] + lotus-miner storage redeclare [command options] [path] OPTIONS: --all redeclare all storage paths (default: false)