add a helper to make printing helptext on errors easier

This commit is contained in:
whyrusleeping 2020-07-23 11:41:53 -07:00
parent d8c3cf11f6
commit f47fea3751
2 changed files with 5 additions and 8 deletions

View File

@ -3,7 +3,6 @@ package main
import (
"context"
"fmt"
"os"
logging "github.com/ipfs/go-log/v2"
"github.com/urfave/cli/v2"
@ -96,10 +95,7 @@ func main() {
app.Setup()
app.Metadata["repoType"] = repo.StorageMiner
if err := app.Run(os.Args); err != nil {
log.Warnf("%+v", err)
os.Exit(1)
}
lcli.RunApp(app)
}
func getActorAddress(ctx context.Context, nodeAPI api.StorageMiner, overrideMaddr string) (maddr address.Address, err error) {

View File

@ -251,15 +251,16 @@ var sectorsMarkForUpgradeCmd = &cli.Command{
Usage: "Mark a committed capacity sector for replacement by a sector with deals",
ArgsUsage: "<sectorNum>",
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)
if err != nil {
return err
}
defer closer()
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)
if err != nil {