Merge pull request #1326 from filecoin-project/asr/cli

Re: #1307: Provide ArgsUsage for all CLI commands
This commit is contained in:
Whyrusleeping 2020-03-05 13:11:04 -08:00 committed by GitHub
commit 1a0bcfe018
10 changed files with 56 additions and 12 deletions

View File

@ -68,6 +68,7 @@ var chainHeadCmd = &cli.Command{
var chainGetBlock = &cli.Command{ var chainGetBlock = &cli.Command{
Name: "getblock", Name: "getblock",
Usage: "Get a block and print its details", Usage: "Get a block and print its details",
ArgsUsage: "[blockCid]",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.BoolFlag{ &cli.BoolFlag{
Name: "raw", Name: "raw",
@ -158,6 +159,7 @@ func apiMsgCids(in []api.Message) []cid.Cid {
var chainReadObjCmd = &cli.Command{ var chainReadObjCmd = &cli.Command{
Name: "read-obj", Name: "read-obj",
Usage: "Read the raw bytes of an object", Usage: "Read the raw bytes of an object",
ArgsUsage: "[objectCid]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)
if err != nil { if err != nil {
@ -184,6 +186,7 @@ var chainReadObjCmd = &cli.Command{
var chainGetMsgCmd = &cli.Command{ var chainGetMsgCmd = &cli.Command{
Name: "getmessage", Name: "getmessage",
Usage: "Get and print a message by its cid", Usage: "Get and print a message by its cid",
ArgsUsage: "[messageCid]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if !cctx.Args().Present() { if !cctx.Args().Present() {
return fmt.Errorf("must pass a cid of a message to get") return fmt.Errorf("must pass a cid of a message to get")
@ -231,6 +234,7 @@ var chainGetMsgCmd = &cli.Command{
var chainSetHeadCmd = &cli.Command{ var chainSetHeadCmd = &cli.Command{
Name: "sethead", Name: "sethead",
Usage: "manually set the local nodes head tipset (Caution: normally only used for recovery)", Usage: "manually set the local nodes head tipset (Caution: normally only used for recovery)",
ArgsUsage: "[tipsetkey]",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.BoolFlag{ &cli.BoolFlag{
Name: "genesis", Name: "genesis",
@ -357,6 +361,7 @@ var chainListCmd = &cli.Command{
var chainGetCmd = &cli.Command{ var chainGetCmd = &cli.Command{
Name: "get", Name: "get",
Usage: "Get chain DAG node by path", Usage: "Get chain DAG node by path",
ArgsUsage: "[path]",
Description: `Get ipld node under a specified path: Description: `Get ipld node under a specified path:
lotus chain get /ipfs/[cid]/some/path lotus chain get /ipfs/[cid]/some/path
@ -414,6 +419,7 @@ func printTipSet(format string, ts *types.TipSet) {
var chainBisectCmd = &cli.Command{ var chainBisectCmd = &cli.Command{
Name: "bisect", Name: "bisect",
Usage: "bisect chain for an event", Usage: "bisect chain for an event",
ArgsUsage: "[minHeight maxHeight path shellCommand <shellCommandArgs (if any)>]",
Description: `Bisect the chain state tree: Description: `Bisect the chain state tree:
lotus chain bisect [min height] [max height] '1/2/3/state/path' 'shell command' 'args' 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{ var chainExportCmd = &cli.Command{
Name: "export", Name: "export",
Usage: "export chain to a car file", Usage: "export chain to a car file",
ArgsUsage: "[outputPath]",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: "tipset", Name: "tipset",
@ -566,6 +573,7 @@ var chainExportCmd = &cli.Command{
var slashConsensusFault = &cli.Command{ var slashConsensusFault = &cli.Command{
Name: "slash-consensus", Name: "slash-consensus",
Usage: "Report consensus fault", Usage: "Report consensus fault",
ArgsUsage: "[blockCid1 blockCid2]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)
if err != nil { if err != nil {

View File

@ -37,6 +37,7 @@ var clientCmd = &cli.Command{
var clientImportCmd = &cli.Command{ var clientImportCmd = &cli.Command{
Name: "import", Name: "import",
Usage: "Import data", Usage: "Import data",
ArgsUsage: "[inputPath]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)
if err != nil { if err != nil {
@ -83,6 +84,7 @@ var clientLocalCmd = &cli.Command{
var clientDealCmd = &cli.Command{ var clientDealCmd = &cli.Command{
Name: "deal", Name: "deal",
Usage: "Initialize storage deal with a miner", Usage: "Initialize storage deal with a miner",
ArgsUsage: "[dataCid miner price duration]",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.BoolFlag{ &cli.BoolFlag{
Name: "manual-transfer", Name: "manual-transfer",
@ -193,6 +195,7 @@ var clientDealCmd = &cli.Command{
var clientFindCmd = &cli.Command{ var clientFindCmd = &cli.Command{
Name: "find", Name: "find",
Usage: "find data in the network", Usage: "find data in the network",
ArgsUsage: "[dataCid]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if !cctx.Args().Present() { if !cctx.Args().Present() {
fmt.Println("Usage: find [CID]") fmt.Println("Usage: find [CID]")
@ -242,6 +245,7 @@ var clientFindCmd = &cli.Command{
var clientRetrieveCmd = &cli.Command{ var clientRetrieveCmd = &cli.Command{
Name: "retrieve", Name: "retrieve",
Usage: "retrieve data from network", Usage: "retrieve data from network",
ArgsUsage: "[dataCid outputPath]",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: "address", Name: "address",
@ -312,6 +316,7 @@ var clientRetrieveCmd = &cli.Command{
var clientQueryAskCmd = &cli.Command{ var clientQueryAskCmd = &cli.Command{
Name: "query-ask", Name: "query-ask",
Usage: "find a miners ask", Usage: "find a miners ask",
ArgsUsage: "[minerAddress]",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: "peerid", Name: "peerid",

View File

@ -44,7 +44,7 @@ var logList = &cli.Command{
var logSetLevel = &cli.Command{ var logSetLevel = &cli.Command{
Name: "set-level", Name: "set-level",
Usage: "Set log level", Usage: "Set log level",
ArgsUsage: "<level>", ArgsUsage: "[level]",
Description: `Set the log level for logging systems: Description: `Set the log level for logging systems:
The system flag can be specified multiple times. The system flag can be specified multiple times.

View File

@ -49,6 +49,7 @@ var multisigCmd = &cli.Command{
var msigCreateCmd = &cli.Command{ var msigCreateCmd = &cli.Command{
Name: "create", Name: "create",
Usage: "Create a new multisig wallet", Usage: "Create a new multisig wallet",
ArgsUsage: "[address1 address2 ...]",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.Int64Flag{ &cli.Int64Flag{
Name: "required", Name: "required",
@ -159,6 +160,7 @@ var msigCreateCmd = &cli.Command{
var msigInspectCmd = &cli.Command{ var msigInspectCmd = &cli.Command{
Name: "inspect", Name: "inspect",
Usage: "Inspect a multisig wallet", Usage: "Inspect a multisig wallet",
ArgsUsage: "[address]",
Flags: []cli.Flag{}, Flags: []cli.Flag{},
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)
@ -271,6 +273,7 @@ func state(tx *samsig.Transaction) string {
var msigProposeCmd = &cli.Command{ var msigProposeCmd = &cli.Command{
Name: "propose", Name: "propose",
Usage: "Propose a multisig transaction", Usage: "Propose a multisig transaction",
ArgsUsage: "[multisigAddress destinationAddress value <methodName methodParams> (optional)]",
Flags: []cli.Flag{}, Flags: []cli.Flag{},
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)
@ -383,7 +386,8 @@ var msigProposeCmd = &cli.Command{
var msigApproveCmd = &cli.Command{ var msigApproveCmd = &cli.Command{
Name: "approve", Name: "approve",
Usage: "Approve a multisig transaction", Usage: "Approve a multisig message",
ArgsUsage: "[multisigAddress messageId]",
Flags: []cli.Flag{}, Flags: []cli.Flag{},
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)
@ -393,8 +397,8 @@ var msigApproveCmd = &cli.Command{
defer closer() defer closer()
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
if cctx.Args().Len() < 2 { if cctx.Args().Len() != 2 {
return fmt.Errorf("must pass multisig address and transaction ID") return fmt.Errorf("must pass multisig address and message ID")
} }
msig, err := address.NewFromString(cctx.Args().Get(0)) msig, err := address.NewFromString(cctx.Args().Get(0))

View File

@ -76,7 +76,7 @@ var netListen = &cli.Command{
var netConnect = &cli.Command{ var netConnect = &cli.Command{
Name: "connect", Name: "connect",
Usage: "Connect to a peer", Usage: "Connect to a peer",
ArgsUsage: "<peer multiaddr>", ArgsUsage: "[peerMultiaddr]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := GetAPI(cctx) api, closer, err := GetAPI(cctx)
if err != nil { if err != nil {
@ -129,7 +129,7 @@ var netId = &cli.Command{
var netFindPeer = &cli.Command{ var netFindPeer = &cli.Command{
Name: "findpeer", Name: "findpeer",
Usage: "Find the addresses of a given peerID", Usage: "Find the addresses of a given peerID",
ArgsUsage: "<peer ID>", ArgsUsage: "[peerId]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
fmt.Println("Usage: findpeer [peer ID]") fmt.Println("Usage: findpeer [peer ID]")

View File

@ -25,6 +25,7 @@ var paychCmd = &cli.Command{
var paychGetCmd = &cli.Command{ var paychGetCmd = &cli.Command{
Name: "get", Name: "get",
Usage: "Create a new payment channel or get existing one", Usage: "Create a new payment channel or get existing one",
ArgsUsage: "[fromAddress toAddress amount]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 3 { if cctx.Args().Len() != 3 {
return fmt.Errorf("must pass three arguments: <from> <to> <available funds>") return fmt.Errorf("must pass three arguments: <from> <to> <available funds>")
@ -103,6 +104,7 @@ var paychVoucherCmd = &cli.Command{
var paychVoucherCreateCmd = &cli.Command{ var paychVoucherCreateCmd = &cli.Command{
Name: "create", Name: "create",
Usage: "Create a signed payment channel voucher", Usage: "Create a signed payment channel voucher",
ArgsUsage: "[channelAddress amount]",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.IntFlag{ &cli.IntFlag{
Name: "lane", Name: "lane",
@ -153,6 +155,7 @@ var paychVoucherCreateCmd = &cli.Command{
var paychVoucherCheckCmd = &cli.Command{ var paychVoucherCheckCmd = &cli.Command{
Name: "check", Name: "check",
Usage: "Check validity of payment channel voucher", Usage: "Check validity of payment channel voucher",
ArgsUsage: "[channelAddress voucher]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 2 { if cctx.Args().Len() != 2 {
return fmt.Errorf("must pass payment channel address and voucher to validate") return fmt.Errorf("must pass payment channel address and voucher to validate")
@ -188,6 +191,7 @@ var paychVoucherCheckCmd = &cli.Command{
var paychVoucherAddCmd = &cli.Command{ var paychVoucherAddCmd = &cli.Command{
Name: "add", Name: "add",
Usage: "Add payment channel voucher to local datastore", Usage: "Add payment channel voucher to local datastore",
ArgsUsage: "[channelAddress voucher]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 2 { if cctx.Args().Len() != 2 {
return fmt.Errorf("must pass payment channel address and voucher") return fmt.Errorf("must pass payment channel address and voucher")
@ -223,6 +227,7 @@ var paychVoucherAddCmd = &cli.Command{
var paychVoucherListCmd = &cli.Command{ var paychVoucherListCmd = &cli.Command{
Name: "list", Name: "list",
Usage: "List stored vouchers for a given payment channel", Usage: "List stored vouchers for a given payment channel",
ArgsUsage: "[channelAddress]",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.BoolFlag{ &cli.BoolFlag{
Name: "export", Name: "export",
@ -272,6 +277,7 @@ var paychVoucherListCmd = &cli.Command{
var paychVoucherBestSpendableCmd = &cli.Command{ var paychVoucherBestSpendableCmd = &cli.Command{
Name: "best-spendable", Name: "best-spendable",
Usage: "Print voucher with highest value that is currently spendable", Usage: "Print voucher with highest value that is currently spendable",
ArgsUsage: "[channelAddress]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 1 { if cctx.Args().Len() != 1 {
return fmt.Errorf("must pass payment channel address") return fmt.Errorf("must pass payment channel address")
@ -326,6 +332,7 @@ var paychVoucherBestSpendableCmd = &cli.Command{
var paychVoucherSubmitCmd = &cli.Command{ var paychVoucherSubmitCmd = &cli.Command{
Name: "submit", Name: "submit",
Usage: "Submit voucher to chain to update payment channel state", Usage: "Submit voucher to chain to update payment channel state",
ArgsUsage: "[channelAddress voucher]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 2 { if cctx.Args().Len() != 2 {
return fmt.Errorf("must pass payment channel address and voucher") return fmt.Errorf("must pass payment channel address and voucher")

View File

@ -11,7 +11,7 @@ import (
var sendCmd = &cli.Command{ var sendCmd = &cli.Command{
Name: "send", Name: "send",
Usage: "Send funds between accounts", Usage: "Send funds between accounts",
ArgsUsage: "<target> <amount>", ArgsUsage: "[targetAddress] [amount]",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: "source", Name: "source",

View File

@ -63,6 +63,7 @@ var stateCmd = &cli.Command{
var stateMinerInfo = &cli.Command{ var stateMinerInfo = &cli.Command{
Name: "miner-info", Name: "miner-info",
Usage: "Retrieve miner information", Usage: "Retrieve miner information",
ArgsUsage: "[minerAddress]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)
if err != nil { if err != nil {
@ -154,6 +155,7 @@ func loadTipSet(ctx context.Context, cctx *cli.Context, api api.FullNode) (*type
var statePowerCmd = &cli.Command{ var statePowerCmd = &cli.Command{
Name: "power", Name: "power",
Usage: "Query network or miner power", Usage: "Query network or miner power",
ArgsUsage: "[<minerAddress> (optional)]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)
if err != nil { if err != nil {
@ -197,6 +199,7 @@ var statePowerCmd = &cli.Command{
var stateSectorsCmd = &cli.Command{ var stateSectorsCmd = &cli.Command{
Name: "sectors", Name: "sectors",
Usage: "Query the sector set of a miner", Usage: "Query the sector set of a miner",
ArgsUsage: "[minerAddress]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)
if err != nil { if err != nil {
@ -236,6 +239,7 @@ var stateSectorsCmd = &cli.Command{
var stateProvingSetCmd = &cli.Command{ var stateProvingSetCmd = &cli.Command{
Name: "proving", Name: "proving",
Usage: "Query the proving set of a miner", Usage: "Query the proving set of a miner",
ArgsUsage: "[minerAddress]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)
if err != nil { if err != nil {
@ -275,6 +279,7 @@ var stateProvingSetCmd = &cli.Command{
var stateReplaySetCmd = &cli.Command{ var stateReplaySetCmd = &cli.Command{
Name: "replay", Name: "replay",
Usage: "Replay a particular message within a tipset", Usage: "Replay a particular message within a tipset",
ArgsUsage: "[tipsetKey messageCid]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.Args().Len() < 1 { if cctx.Args().Len() < 1 {
fmt.Println("usage: [tipset] <message cid>") fmt.Println("usage: [tipset] <message cid>")
@ -381,6 +386,7 @@ var statePledgeCollateralCmd = &cli.Command{
var stateGetDealSetCmd = &cli.Command{ var stateGetDealSetCmd = &cli.Command{
Name: "get-deal", Name: "get-deal",
Usage: "View on-chain deal info", Usage: "View on-chain deal info",
ArgsUsage: "[dealId]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)
if err != nil { if err != nil {
@ -391,7 +397,7 @@ var stateGetDealSetCmd = &cli.Command{
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
if !cctx.Args().Present() { 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) dealid, err := strconv.ParseUint(cctx.Args().First(), 10, 64)
@ -482,6 +488,7 @@ var stateListActorsCmd = &cli.Command{
var stateGetActorCmd = &cli.Command{ var stateGetActorCmd = &cli.Command{
Name: "get-actor", Name: "get-actor",
Usage: "Print actor information", Usage: "Print actor information",
ArgsUsage: "[actorrAddress]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)
if err != nil { if err != nil {
@ -523,6 +530,7 @@ var stateGetActorCmd = &cli.Command{
var stateLookupIDCmd = &cli.Command{ var stateLookupIDCmd = &cli.Command{
Name: "lookup", Name: "lookup",
Usage: "Find corresponding ID address", Usage: "Find corresponding ID address",
ArgsUsage: "[address]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)
if err != nil { if err != nil {
@ -560,6 +568,7 @@ var stateLookupIDCmd = &cli.Command{
var stateSectorSizeCmd = &cli.Command{ var stateSectorSizeCmd = &cli.Command{
Name: "sector-size", Name: "sector-size",
Usage: "Look up miners sector size", Usage: "Look up miners sector size",
ArgsUsage: "[minerAddress]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)
if err != nil { if err != nil {
@ -570,7 +579,7 @@ var stateSectorSizeCmd = &cli.Command{
ctx := ReqContext(cctx) ctx := ReqContext(cctx)
if !cctx.Args().Present() { 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()) addr, err := address.NewFromString(cctx.Args().First())
@ -596,6 +605,7 @@ var stateSectorSizeCmd = &cli.Command{
var stateReadStateCmd = &cli.Command{ var stateReadStateCmd = &cli.Command{
Name: "read-state", Name: "read-state",
Usage: "View a json representation of an actors state", Usage: "View a json representation of an actors state",
ArgsUsage: "[actorAddress]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)
if err != nil { if err != nil {
@ -788,6 +798,7 @@ var stateComputeStateCmd = &cli.Command{
var stateWaitMsgCmd = &cli.Command{ var stateWaitMsgCmd = &cli.Command{
Name: "wait-msg", Name: "wait-msg",
Usage: "Wait for a message to appear on chain", Usage: "Wait for a message to appear on chain",
ArgsUsage: "[messageCid]",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: "timeout", Name: "timeout",
@ -828,6 +839,7 @@ var stateWaitMsgCmd = &cli.Command{
var stateCallCmd = &cli.Command{ var stateCallCmd = &cli.Command{
Name: "call", Name: "call",
Usage: "Invoke a method on an actor locally", Usage: "Invoke a method on an actor locally",
ArgsUsage: "[toAddress methodId <param1 param2 ...> (optional)]",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: "from", Name: "from",

View File

@ -96,6 +96,7 @@ var syncWaitCmd = &cli.Command{
var syncMarkBadCmd = &cli.Command{ var syncMarkBadCmd = &cli.Command{
Name: "mark-bad", Name: "mark-bad",
Usage: "Mark the given block as bad, will prevent syncing to a chain that contains it", Usage: "Mark the given block as bad, will prevent syncing to a chain that contains it",
ArgsUsage: "[blockCid]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
napi, closer, err := GetFullNodeAPI(cctx) napi, closer, err := GetFullNodeAPI(cctx)
if err != nil { if err != nil {
@ -120,6 +121,7 @@ var syncMarkBadCmd = &cli.Command{
var syncCheckBadCmd = &cli.Command{ var syncCheckBadCmd = &cli.Command{
Name: "check-bad", Name: "check-bad",
Usage: "check if the given block was marked bad, and for what reason", Usage: "check if the given block was marked bad, and for what reason",
ArgsUsage: "[blockCid]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
napi, closer, err := GetFullNodeAPI(cctx) napi, closer, err := GetFullNodeAPI(cctx)
if err != nil { if err != nil {

View File

@ -1,6 +1,7 @@
package cli package cli
import ( import (
"bufio"
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"fmt" "fmt"
@ -32,7 +33,7 @@ var walletCmd = &cli.Command{
var walletNew = &cli.Command{ var walletNew = &cli.Command{
Name: "new", Name: "new",
Usage: "Generate a new key of the given type", Usage: "Generate a new key of the given type",
ArgsUsage: "[bls|secp256k1]", ArgsUsage: "[bls|secp256k1 (default secp256k1)]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)
if err != nil { if err != nil {
@ -83,7 +84,7 @@ var walletList = &cli.Command{
var walletBalance = &cli.Command{ var walletBalance = &cli.Command{
Name: "balance", Name: "balance",
Usage: "Get account balance", Usage: "Get account balance",
ArgsUsage: "[account address]", ArgsUsage: "[address]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)
if err != nil { if err != nil {
@ -136,6 +137,7 @@ var walletGetDefault = &cli.Command{
var walletSetDefault = &cli.Command{ var walletSetDefault = &cli.Command{
Name: "set-default", Name: "set-default",
Usage: "Set default wallet address", Usage: "Set default wallet address",
ArgsUsage: "[address]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)
if err != nil { if err != nil {
@ -160,6 +162,7 @@ var walletSetDefault = &cli.Command{
var walletExport = &cli.Command{ var walletExport = &cli.Command{
Name: "export", Name: "export",
Usage: "export keys", Usage: "export keys",
ArgsUsage: "[address]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)
if err != nil { if err != nil {
@ -195,6 +198,7 @@ var walletExport = &cli.Command{
var walletImport = &cli.Command{ var walletImport = &cli.Command{
Name: "import", Name: "import",
Usage: "import keys", Usage: "import keys",
ArgsUsage: "[<path> (optional, will read from stdin if omitted)]",
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx) api, closer, err := GetFullNodeAPI(cctx)
if err != nil { if err != nil {
@ -205,7 +209,9 @@ var walletImport = &cli.Command{
var hexdata []byte var hexdata []byte
if !cctx.Args().Present() || cctx.Args().First() == "-" { if !cctx.Args().Present() || cctx.Args().First() == "-" {
indata, err := ioutil.ReadAll(os.Stdin) reader := bufio.NewReader(os.Stdin)
fmt.Print("Enter private key: ")
indata, err := reader.ReadBytes('\n')
if err != nil { if err != nil {
return err return err
} }