Add helper function to print usage when wrong number of arguments are supplied

This commit is contained in:
Geoff Stuart
2022-09-14 15:38:15 -04:00
parent 3ca9b1e331
commit 4f75e2041c
39 changed files with 108 additions and 102 deletions
+4 -4
View File
@@ -130,7 +130,7 @@ var clientImportCmd = &cli.Command{
ctx := ReqContext(cctx)
if cctx.NArg() != 1 {
return xerrors.New("expected input path as the only arg")
return IncorrectNumArgs(cctx)
}
absPath, err := filepath.Abs(cctx.Args().First())
@@ -213,7 +213,7 @@ var clientCommPCmd = &cli.Command{
ctx := ReqContext(cctx)
if cctx.NArg() != 1 {
return fmt.Errorf("usage: commP <inputPath>")
return IncorrectNumArgs(cctx)
}
ret, err := api.ClientCalcCommP(ctx, cctx.Args().Get(0))
@@ -246,7 +246,7 @@ var clientCarGenCmd = &cli.Command{
ctx := ReqContext(cctx)
if cctx.NArg() != 2 {
return fmt.Errorf("usage: generate-car <inputPath> <outputPath>")
return IncorrectNumArgs(cctx)
}
ref := lapi.FileRef{
@@ -376,7 +376,7 @@ The minimum value is 518400 (6 months).`,
afmt := NewAppFmt(cctx.App)
if cctx.NArg() != 4 {
return xerrors.New(expectedArgsMsg)
return IncorrectNumArgs(cctx)
}
// [data, miner, price, dur]