From e9afba3490ae52c8f5adc2be06b2bc7404445d96 Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Wed, 4 Mar 2020 13:46:00 -0800 Subject: [PATCH] Add ArgsUsages to the CLI where missing - This commit also standardises some notation --- cli/chain.go | 8 ++++++++ cli/client.go | 5 +++++ cli/log.go | 2 +- cli/multisig.go | 10 +++++++--- cli/net.go | 4 ++-- cli/paych.go | 7 +++++++ cli/send.go | 2 +- cli/state.go | 16 ++++++++++++++-- cli/sync.go | 2 ++ cli/wallet.go | 7 +++++-- 10 files changed, 52 insertions(+), 11 deletions(-) diff --git a/cli/chain.go b/cli/chain.go index 1bebc78e9..b1a5c1b6a 100644 --- a/cli/chain.go +++ b/cli/chain.go @@ -68,6 +68,7 @@ var chainHeadCmd = &cli.Command{ var chainGetBlock = &cli.Command{ Name: "getblock", Usage: "Get a block and print its details", + ArgsUsage: "[blockCid]", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "raw", @@ -158,6 +159,7 @@ func apiMsgCids(in []api.Message) []cid.Cid { var chainReadObjCmd = &cli.Command{ Name: "read-obj", Usage: "Read the raw bytes of an object", + ArgsUsage: "[objectCid]", Action: func(cctx *cli.Context) error { api, closer, err := GetFullNodeAPI(cctx) if err != nil { @@ -184,6 +186,7 @@ var chainReadObjCmd = &cli.Command{ var chainGetMsgCmd = &cli.Command{ Name: "getmessage", Usage: "Get and print a message by its cid", + ArgsUsage: "[messageCid]", Action: func(cctx *cli.Context) error { if !cctx.Args().Present() { return fmt.Errorf("must pass a cid of a message to get") @@ -231,6 +234,7 @@ var chainGetMsgCmd = &cli.Command{ var chainSetHeadCmd = &cli.Command{ Name: "sethead", Usage: "manually set the local nodes head tipset (Caution: normally only used for recovery)", + ArgsUsage: "[tipsetkey]", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "genesis", @@ -357,6 +361,7 @@ var chainListCmd = &cli.Command{ var chainGetCmd = &cli.Command{ Name: "get", Usage: "Get chain DAG node by path", + ArgsUsage: "[path]", Description: `Get ipld node under a specified path: lotus chain get /ipfs/[cid]/some/path @@ -414,6 +419,7 @@ func printTipSet(format string, ts *types.TipSet) { var chainBisectCmd = &cli.Command{ Name: "bisect", Usage: "bisect chain for an event", + ArgsUsage: "[minHeight maxHeight path shellCommand ]", Description: `Bisect the chain state tree: lotus chain bisect [min height] [max height] '1/2/3/state/path' 'shell command' 'args' @@ -519,6 +525,7 @@ var chainBisectCmd = &cli.Command{ var chainExportCmd = &cli.Command{ Name: "export", Usage: "export chain to a car file", + ArgsUsage: "[outputPath]", Flags: []cli.Flag{ &cli.StringFlag{ Name: "tipset", @@ -566,6 +573,7 @@ var chainExportCmd = &cli.Command{ var slashConsensusFault = &cli.Command{ Name: "slash-consensus", Usage: "Report consensus fault", + ArgsUsage: "[blockCid1 blockCid2]", Action: func(cctx *cli.Context) error { api, closer, err := GetFullNodeAPI(cctx) if err != nil { diff --git a/cli/client.go b/cli/client.go index 20339753c..3150840dc 100644 --- a/cli/client.go +++ b/cli/client.go @@ -37,6 +37,7 @@ var clientCmd = &cli.Command{ var clientImportCmd = &cli.Command{ Name: "import", Usage: "Import data", + ArgsUsage: "[inputPath]", Action: func(cctx *cli.Context) error { api, closer, err := GetFullNodeAPI(cctx) if err != nil { @@ -83,6 +84,7 @@ var clientLocalCmd = &cli.Command{ var clientDealCmd = &cli.Command{ Name: "deal", Usage: "Initialize storage deal with a miner", + ArgsUsage: "[dataCid miner price duration]", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "manual-transfer", @@ -193,6 +195,7 @@ var clientDealCmd = &cli.Command{ var clientFindCmd = &cli.Command{ Name: "find", Usage: "find data in the network", + ArgsUsage: "[dataCid]", Action: func(cctx *cli.Context) error { if !cctx.Args().Present() { fmt.Println("Usage: find [CID]") @@ -242,6 +245,7 @@ var clientFindCmd = &cli.Command{ var clientRetrieveCmd = &cli.Command{ Name: "retrieve", Usage: "retrieve data from network", + ArgsUsage: "[dataCid outputPath]", Flags: []cli.Flag{ &cli.StringFlag{ Name: "address", @@ -312,6 +316,7 @@ var clientRetrieveCmd = &cli.Command{ var clientQueryAskCmd = &cli.Command{ Name: "query-ask", Usage: "find a miners ask", + ArgsUsage: "[minerAddress]", Flags: []cli.Flag{ &cli.StringFlag{ Name: "peerid", diff --git a/cli/log.go b/cli/log.go index 152a855f6..561d949d5 100644 --- a/cli/log.go +++ b/cli/log.go @@ -44,7 +44,7 @@ var logList = &cli.Command{ var logSetLevel = &cli.Command{ Name: "set-level", Usage: "Set log level", - ArgsUsage: "", + ArgsUsage: "[level]", Description: `Set the log level for logging systems: The system flag can be specified multiple times. diff --git a/cli/multisig.go b/cli/multisig.go index 91959d6b3..877fd41a4 100644 --- a/cli/multisig.go +++ b/cli/multisig.go @@ -49,6 +49,7 @@ var multisigCmd = &cli.Command{ var msigCreateCmd = &cli.Command{ Name: "create", Usage: "Create a new multisig wallet", + ArgsUsage: "[address1 address2 ...]", Flags: []cli.Flag{ &cli.Int64Flag{ Name: "required", @@ -159,6 +160,7 @@ var msigCreateCmd = &cli.Command{ var msigInspectCmd = &cli.Command{ Name: "inspect", Usage: "Inspect a multisig wallet", + ArgsUsage: "[address]", Flags: []cli.Flag{}, Action: func(cctx *cli.Context) error { api, closer, err := GetFullNodeAPI(cctx) @@ -271,6 +273,7 @@ func state(tx *samsig.Transaction) string { var msigProposeCmd = &cli.Command{ Name: "propose", Usage: "Propose a multisig transaction", + ArgsUsage: "[multisigAddress destinationAddress value (optional)]", Flags: []cli.Flag{}, Action: func(cctx *cli.Context) error { api, closer, err := GetFullNodeAPI(cctx) @@ -383,7 +386,8 @@ var msigProposeCmd = &cli.Command{ var msigApproveCmd = &cli.Command{ Name: "approve", - Usage: "Approve a multisig transaction", + Usage: "Approve a multisig message", + ArgsUsage: "[multisigAddress messageId]", Flags: []cli.Flag{}, Action: func(cctx *cli.Context) error { api, closer, err := GetFullNodeAPI(cctx) @@ -393,8 +397,8 @@ var msigApproveCmd = &cli.Command{ defer closer() ctx := ReqContext(cctx) - if cctx.Args().Len() < 2 { - return fmt.Errorf("must pass multisig address and transaction ID") + if cctx.Args().Len() != 2 { + return fmt.Errorf("must pass multisig address and message ID") } msig, err := address.NewFromString(cctx.Args().Get(0)) diff --git a/cli/net.go b/cli/net.go index ac559e919..cf634df64 100644 --- a/cli/net.go +++ b/cli/net.go @@ -76,7 +76,7 @@ var netListen = &cli.Command{ var netConnect = &cli.Command{ Name: "connect", Usage: "Connect to a peer", - ArgsUsage: "", + ArgsUsage: "[peerMultiaddr]", Action: func(cctx *cli.Context) error { api, closer, err := GetAPI(cctx) if err != nil { @@ -129,7 +129,7 @@ var netId = &cli.Command{ var netFindPeer = &cli.Command{ Name: "findpeer", Usage: "Find the addresses of a given peerID", - ArgsUsage: "", + ArgsUsage: "[peerId]", Action: func(cctx *cli.Context) error { if cctx.NArg() != 1 { fmt.Println("Usage: findpeer [peer ID]") diff --git a/cli/paych.go b/cli/paych.go index 5d42a0ea5..4d2077e75 100644 --- a/cli/paych.go +++ b/cli/paych.go @@ -25,6 +25,7 @@ var paychCmd = &cli.Command{ var paychGetCmd = &cli.Command{ Name: "get", Usage: "Create a new payment channel or get existing one", + ArgsUsage: "[fromAddress toAddress amount]", Action: func(cctx *cli.Context) error { if cctx.Args().Len() != 3 { return fmt.Errorf("must pass three arguments: ") @@ -103,6 +104,7 @@ var paychVoucherCmd = &cli.Command{ var paychVoucherCreateCmd = &cli.Command{ Name: "create", Usage: "Create a signed payment channel voucher", + ArgsUsage: "[channelAddress amount]", Flags: []cli.Flag{ &cli.IntFlag{ Name: "lane", @@ -153,6 +155,7 @@ var paychVoucherCreateCmd = &cli.Command{ var paychVoucherCheckCmd = &cli.Command{ Name: "check", Usage: "Check validity of payment channel voucher", + ArgsUsage: "[channelAddress voucher]", Action: func(cctx *cli.Context) error { if cctx.Args().Len() != 2 { return fmt.Errorf("must pass payment channel address and voucher to validate") @@ -188,6 +191,7 @@ var paychVoucherCheckCmd = &cli.Command{ var paychVoucherAddCmd = &cli.Command{ Name: "add", Usage: "Add payment channel voucher to local datastore", + ArgsUsage: "[channelAddress voucher]", Action: func(cctx *cli.Context) error { if cctx.Args().Len() != 2 { return fmt.Errorf("must pass payment channel address and voucher") @@ -223,6 +227,7 @@ var paychVoucherAddCmd = &cli.Command{ var paychVoucherListCmd = &cli.Command{ Name: "list", Usage: "List stored vouchers for a given payment channel", + ArgsUsage: "[channelAddress]", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "export", @@ -272,6 +277,7 @@ var paychVoucherListCmd = &cli.Command{ var paychVoucherBestSpendableCmd = &cli.Command{ Name: "best-spendable", Usage: "Print voucher with highest value that is currently spendable", + ArgsUsage: "[channelAddress]", Action: func(cctx *cli.Context) error { if cctx.Args().Len() != 1 { return fmt.Errorf("must pass payment channel address") @@ -326,6 +332,7 @@ var paychVoucherBestSpendableCmd = &cli.Command{ var paychVoucherSubmitCmd = &cli.Command{ Name: "submit", Usage: "Submit voucher to chain to update payment channel state", + ArgsUsage: "[channelAddress voucher]", Action: func(cctx *cli.Context) error { if cctx.Args().Len() != 2 { return fmt.Errorf("must pass payment channel address and voucher") diff --git a/cli/send.go b/cli/send.go index d4883dd61..1a329ddad 100644 --- a/cli/send.go +++ b/cli/send.go @@ -11,7 +11,7 @@ import ( var sendCmd = &cli.Command{ Name: "send", Usage: "Send funds between accounts", - ArgsUsage: " ", + ArgsUsage: "[targetAddress] [amount]", Flags: []cli.Flag{ &cli.StringFlag{ Name: "source", diff --git a/cli/state.go b/cli/state.go index 5e489ed7c..ca6ce888c 100644 --- a/cli/state.go +++ b/cli/state.go @@ -63,6 +63,7 @@ var stateCmd = &cli.Command{ var stateMinerInfo = &cli.Command{ Name: "miner-info", Usage: "Retrieve miner information", + ArgsUsage: "[minerAddress]", Action: func(cctx *cli.Context) error { api, closer, err := GetFullNodeAPI(cctx) if err != nil { @@ -154,6 +155,7 @@ func loadTipSet(ctx context.Context, cctx *cli.Context, api api.FullNode) (*type var statePowerCmd = &cli.Command{ Name: "power", Usage: "Query network or miner power", + ArgsUsage: "[ (optional)]", Action: func(cctx *cli.Context) error { api, closer, err := GetFullNodeAPI(cctx) if err != nil { @@ -197,6 +199,7 @@ var statePowerCmd = &cli.Command{ var stateSectorsCmd = &cli.Command{ Name: "sectors", Usage: "Query the sector set of a miner", + ArgsUsage: "[minerAddress]", Action: func(cctx *cli.Context) error { api, closer, err := GetFullNodeAPI(cctx) if err != nil { @@ -236,6 +239,7 @@ var stateSectorsCmd = &cli.Command{ var stateProvingSetCmd = &cli.Command{ Name: "proving", Usage: "Query the proving set of a miner", + ArgsUsage: "[minerAddress]", Action: func(cctx *cli.Context) error { api, closer, err := GetFullNodeAPI(cctx) if err != nil { @@ -275,6 +279,7 @@ var stateProvingSetCmd = &cli.Command{ var stateReplaySetCmd = &cli.Command{ Name: "replay", Usage: "Replay a particular message within a tipset", + ArgsUsage: "[tipsetKey messageCid]", Action: func(cctx *cli.Context) error { if cctx.Args().Len() < 1 { fmt.Println("usage: [tipset] ") @@ -381,6 +386,7 @@ var statePledgeCollateralCmd = &cli.Command{ var stateGetDealSetCmd = &cli.Command{ Name: "get-deal", Usage: "View on-chain deal info", + ArgsUsage: "[dealId]", Action: func(cctx *cli.Context) error { api, closer, err := GetFullNodeAPI(cctx) if err != nil { @@ -391,7 +397,7 @@ var stateGetDealSetCmd = &cli.Command{ ctx := ReqContext(cctx) if !cctx.Args().Present() { - return fmt.Errorf("must specify miner to list sectors for") + return fmt.Errorf("must specify deal ID") } dealid, err := strconv.ParseUint(cctx.Args().First(), 10, 64) @@ -482,6 +488,7 @@ var stateListActorsCmd = &cli.Command{ var stateGetActorCmd = &cli.Command{ Name: "get-actor", Usage: "Print actor information", + ArgsUsage: "[actorrAddress]", Action: func(cctx *cli.Context) error { api, closer, err := GetFullNodeAPI(cctx) if err != nil { @@ -523,6 +530,7 @@ var stateGetActorCmd = &cli.Command{ var stateLookupIDCmd = &cli.Command{ Name: "lookup", Usage: "Find corresponding ID address", + ArgsUsage: "[address]", Action: func(cctx *cli.Context) error { api, closer, err := GetFullNodeAPI(cctx) if err != nil { @@ -560,6 +568,7 @@ var stateLookupIDCmd = &cli.Command{ var stateSectorSizeCmd = &cli.Command{ Name: "sector-size", Usage: "Look up miners sector size", + ArgsUsage: "[minerAddress]", Action: func(cctx *cli.Context) error { api, closer, err := GetFullNodeAPI(cctx) if err != nil { @@ -570,7 +579,7 @@ var stateSectorSizeCmd = &cli.Command{ ctx := ReqContext(cctx) if !cctx.Args().Present() { - return fmt.Errorf("must pass address of actor to get") + return fmt.Errorf("must pass miner's address") } addr, err := address.NewFromString(cctx.Args().First()) @@ -596,6 +605,7 @@ var stateSectorSizeCmd = &cli.Command{ var stateReadStateCmd = &cli.Command{ Name: "read-state", Usage: "View a json representation of an actors state", + ArgsUsage: "[actorAddress]", Action: func(cctx *cli.Context) error { api, closer, err := GetFullNodeAPI(cctx) if err != nil { @@ -788,6 +798,7 @@ var stateComputeStateCmd = &cli.Command{ var stateWaitMsgCmd = &cli.Command{ Name: "wait-msg", Usage: "Wait for a message to appear on chain", + ArgsUsage: "[messageCid]", Flags: []cli.Flag{ &cli.StringFlag{ Name: "timeout", @@ -828,6 +839,7 @@ var stateWaitMsgCmd = &cli.Command{ var stateCallCmd = &cli.Command{ Name: "call", Usage: "Invoke a method on an actor locally", + ArgsUsage: "[toAddress methodId (optional)]", Flags: []cli.Flag{ &cli.StringFlag{ Name: "from", diff --git a/cli/sync.go b/cli/sync.go index 588fcf91e..0cde9c97e 100644 --- a/cli/sync.go +++ b/cli/sync.go @@ -96,6 +96,7 @@ var syncWaitCmd = &cli.Command{ var syncMarkBadCmd = &cli.Command{ Name: "mark-bad", Usage: "Mark the given block as bad, will prevent syncing to a chain that contains it", + ArgsUsage: "[blockCid]", Action: func(cctx *cli.Context) error { napi, closer, err := GetFullNodeAPI(cctx) if err != nil { @@ -120,6 +121,7 @@ var syncMarkBadCmd = &cli.Command{ var syncCheckBadCmd = &cli.Command{ Name: "check-bad", Usage: "check if the given block was marked bad, and for what reason", + ArgsUsage: "[blockCid]", Action: func(cctx *cli.Context) error { napi, closer, err := GetFullNodeAPI(cctx) if err != nil { diff --git a/cli/wallet.go b/cli/wallet.go index 69cd8d83c..b7123b594 100644 --- a/cli/wallet.go +++ b/cli/wallet.go @@ -33,7 +33,7 @@ var walletCmd = &cli.Command{ var walletNew = &cli.Command{ Name: "new", Usage: "Generate a new key of the given type", - ArgsUsage: "[bls|secp256k1]", + ArgsUsage: "[bls|secp256k1 (default secp256k1)]", Action: func(cctx *cli.Context) error { api, closer, err := GetFullNodeAPI(cctx) if err != nil { @@ -84,7 +84,7 @@ var walletList = &cli.Command{ var walletBalance = &cli.Command{ Name: "balance", Usage: "Get account balance", - ArgsUsage: "[account address]", + ArgsUsage: "[address]", Action: func(cctx *cli.Context) error { api, closer, err := GetFullNodeAPI(cctx) if err != nil { @@ -137,6 +137,7 @@ var walletGetDefault = &cli.Command{ var walletSetDefault = &cli.Command{ Name: "set-default", Usage: "Set default wallet address", + ArgsUsage: "[address]", Action: func(cctx *cli.Context) error { api, closer, err := GetFullNodeAPI(cctx) if err != nil { @@ -161,6 +162,7 @@ var walletSetDefault = &cli.Command{ var walletExport = &cli.Command{ Name: "export", Usage: "export keys", + ArgsUsage: "[address]", Action: func(cctx *cli.Context) error { api, closer, err := GetFullNodeAPI(cctx) if err != nil { @@ -196,6 +198,7 @@ var walletExport = &cli.Command{ var walletImport = &cli.Command{ Name: "import", Usage: "import keys", + ArgsUsage: "[ (optional, will read from stdin if omitted)]", Action: func(cctx *cli.Context) error { api, closer, err := GetFullNodeAPI(cctx) if err != nil {