add a helper to make printing helptext on errors easier
This commit is contained in:
parent
d8c3cf11f6
commit
f47fea3751
@ -3,7 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
|
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
@ -96,10 +95,7 @@ func main() {
|
|||||||
app.Setup()
|
app.Setup()
|
||||||
app.Metadata["repoType"] = repo.StorageMiner
|
app.Metadata["repoType"] = repo.StorageMiner
|
||||||
|
|
||||||
if err := app.Run(os.Args); err != nil {
|
lcli.RunApp(app)
|
||||||
log.Warnf("%+v", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getActorAddress(ctx context.Context, nodeAPI api.StorageMiner, overrideMaddr string) (maddr address.Address, err error) {
|
func getActorAddress(ctx context.Context, nodeAPI api.StorageMiner, overrideMaddr string) (maddr address.Address, err error) {
|
||||||
|
@ -251,15 +251,16 @@ var sectorsMarkForUpgradeCmd = &cli.Command{
|
|||||||
Usage: "Mark a committed capacity sector for replacement by a sector with deals",
|
Usage: "Mark a committed capacity sector for replacement by a sector with deals",
|
||||||
ArgsUsage: "<sectorNum>",
|
ArgsUsage: "<sectorNum>",
|
||||||
Action: func(cctx *cli.Context) error {
|
Action: func(cctx *cli.Context) error {
|
||||||
|
if cctx.Args().Len() != 1 {
|
||||||
|
return lcli.ShowHelp(cctx, xerrors.Errorf("must pass sector number"))
|
||||||
|
}
|
||||||
|
|
||||||
nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx)
|
nodeApi, closer, err := lcli.GetStorageMinerAPI(cctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer closer()
|
defer closer()
|
||||||
ctx := lcli.ReqContext(cctx)
|
ctx := lcli.ReqContext(cctx)
|
||||||
if cctx.Args().Len() != 1 {
|
|
||||||
return xerrors.Errorf("must pass sector number")
|
|
||||||
}
|
|
||||||
|
|
||||||
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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user