Merge pull request #10147 from filecoin-project/fix/add-args-usage

This commit is contained in:
Phi-rjan 2023-01-31 13:03:13 +01:00 committed by GitHub
commit b8e7262b14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 27 deletions

View File

@ -55,9 +55,10 @@ var actorCmd = &cli.Command{
} }
var actorSetAddrsCmd = &cli.Command{ var actorSetAddrsCmd = &cli.Command{
Name: "set-addresses", Name: "set-addresses",
Aliases: []string{"set-addrs"}, Aliases: []string{"set-addrs"},
Usage: "set addresses that your miner can be publicly dialed on", Usage: "set addresses that your miner can be publicly dialed on",
ArgsUsage: "<multiaddrs>",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: "from", Name: "from",
@ -170,8 +171,9 @@ var actorSetAddrsCmd = &cli.Command{
} }
var actorSetPeeridCmd = &cli.Command{ var actorSetPeeridCmd = &cli.Command{
Name: "set-peer-id", Name: "set-peer-id",
Usage: "set the peer id of your miner", Usage: "set the peer id of your miner",
ArgsUsage: "<peer id>",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.Int64Flag{ &cli.Int64Flag{
Name: "gas-limit", Name: "gas-limit",
@ -194,6 +196,10 @@ var actorSetPeeridCmd = &cli.Command{
ctx := lcli.ReqContext(cctx) ctx := lcli.ReqContext(cctx)
if cctx.NArg() != 1 {
return lcli.IncorrectNumArgs(cctx)
}
pid, err := peer.Decode(cctx.Args().Get(0)) pid, err := peer.Decode(cctx.Args().Get(0))
if err != nil { if err != nil {
return fmt.Errorf("failed to parse input as a peerId: %w", err) 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 { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 2 {
return lcli.IncorrectNumArgs(cctx)
}
if !cctx.Bool("really-do-it") { if !cctx.Bool("really-do-it") {
fmt.Println("Pass --really-do-it to actually execute this action") fmt.Println("Pass --really-do-it to actually execute this action")
return nil return nil
} }
if cctx.NArg() != 2 {
return lcli.IncorrectNumArgs(cctx)
}
api, acloser, err := lcli.GetFullNodeAPI(cctx) api, acloser, err := lcli.GetFullNodeAPI(cctx)
if err != nil { if err != nil {
return err return err

View File

@ -120,8 +120,8 @@ var sectorsStatusCmd = &cli.Command{
defer closer() defer closer()
ctx := lcli.ReqContext(cctx) ctx := lcli.ReqContext(cctx)
if !cctx.Args().Present() { if cctx.NArg() != 1 {
return fmt.Errorf("must specify sector number to get status of") return lcli.IncorrectNumArgs(cctx)
} }
id, err := strconv.ParseUint(cctx.Args().First(), 10, 64) id, err := strconv.ParseUint(cctx.Args().First(), 10, 64)
@ -1145,9 +1145,6 @@ var sectorsTerminateCmd = &cli.Command{
sectorsTerminatePendingCmd, sectorsTerminatePendingCmd,
}, },
Action: func(cctx *cli.Context) error { 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) minerApi, closer, err := lcli.GetStorageMinerAPI(cctx)
if err != nil { if err != nil {
return err return err
@ -1158,6 +1155,10 @@ var sectorsTerminateCmd = &cli.Command{
return lcli.IncorrectNumArgs(cctx) 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) id, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64)
if err != nil { if err != nil {
return xerrors.Errorf("could not parse sector number: %w", err) return xerrors.Errorf("could not parse sector number: %w", err)
@ -1490,8 +1491,8 @@ 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 lcli.ShowHelp(cctx, xerrors.Errorf("must pass sector number and new state")) return lcli.IncorrectNumArgs(cctx)
} }
id, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64) id, err := strconv.ParseUint(cctx.Args().Get(0), 10, 64)

View File

@ -55,8 +55,9 @@ stored while moving through the sealing pipeline (references as 'seal').`,
} }
var storageAttachCmd = &cli.Command{ var storageAttachCmd = &cli.Command{
Name: "attach", Name: "attach",
Usage: "attach local storage path", Usage: "attach local storage path",
ArgsUsage: "[path]",
Description: `Storage can be attached to the miner using this command. The storage volume 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 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 recommend manually modifying this value without further understanding of the
@ -115,8 +116,8 @@ over time
defer closer() defer closer()
ctx := lcli.ReqContext(cctx) ctx := lcli.ReqContext(cctx)
if !cctx.Args().Present() { if cctx.NArg() != 1 {
return xerrors.Errorf("must specify storage path to attach") return lcli.IncorrectNumArgs(cctx)
} }
p, err := homedir.Expand(cctx.Args().First()) p, err := homedir.Expand(cctx.Args().First())
@ -192,8 +193,8 @@ var storageDetachCmd = &cli.Command{
defer closer() defer closer()
ctx := lcli.ReqContext(cctx) ctx := lcli.ReqContext(cctx)
if !cctx.Args().Present() { if cctx.NArg() != 1 {
return xerrors.Errorf("must specify storage path") return lcli.IncorrectNumArgs(cctx)
} }
p, err := homedir.Expand(cctx.Args().First()) p, err := homedir.Expand(cctx.Args().First())
@ -210,8 +211,9 @@ var storageDetachCmd = &cli.Command{
} }
var storageRedeclareCmd = &cli.Command{ var storageRedeclareCmd = &cli.Command{
Name: "redeclare", Name: "redeclare",
Usage: "redeclare sectors in a local storage path", Usage: "redeclare sectors in a local storage path",
ArgsUsage: "[path]",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: "id", Name: "id",
@ -234,6 +236,10 @@ var storageRedeclareCmd = &cli.Command{
defer closer() defer closer()
ctx := lcli.ReqContext(cctx) ctx := lcli.ReqContext(cctx)
if cctx.NArg() != 1 {
return lcli.IncorrectNumArgs(cctx)
}
if cctx.IsSet("id") && cctx.Bool("all") { if cctx.IsSet("id") && cctx.Bool("all") {
return xerrors.Errorf("--id and --all can't be passed at the same time") return xerrors.Errorf("--id and --all can't be passed at the same time")
} }
@ -466,6 +472,10 @@ var storageFindCmd = &cli.Command{
defer closer() defer closer()
ctx := lcli.ReqContext(cctx) ctx := lcli.ReqContext(cctx)
if cctx.NArg() != 1 {
return lcli.IncorrectNumArgs(cctx)
}
ma, err := minerApi.ActorAddress(ctx) ma, err := minerApi.ActorAddress(ctx)
if err != nil { if err != nil {
return err return err

View File

@ -286,7 +286,7 @@ NAME:
lotus-miner actor set-peer-id - set the peer id of your miner lotus-miner actor set-peer-id - set the peer id of your miner
USAGE: USAGE:
lotus-miner actor set-peer-id [command options] [arguments...] lotus-miner actor set-peer-id [command options] <peer id>
OPTIONS: OPTIONS:
--gas-limit value set gas limit (default: 0) --gas-limit value set gas limit (default: 0)
@ -2273,7 +2273,7 @@ NAME:
lotus-miner storage attach - attach local storage path lotus-miner storage attach - attach local storage path
USAGE: USAGE:
lotus-miner storage attach [command options] [arguments...] lotus-miner storage attach [command options] [path]
DESCRIPTION: DESCRIPTION:
Storage can be attached to the miner using this command. The storage volume 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 lotus-miner storage redeclare - redeclare sectors in a local storage path
USAGE: USAGE:
lotus-miner storage redeclare [command options] [arguments...] lotus-miner storage redeclare [command options] [path]
OPTIONS: OPTIONS:
--all redeclare all storage paths (default: false) --all redeclare all storage paths (default: false)