From ad106bcefda295c62aa068ae6641d2515800268f Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Tue, 1 May 2018 14:28:30 +0300 Subject: [PATCH 1/2] lncli: group commands into categories --- cmd/lncli/commands.go | 113 +++++++++++++++++++++++++++--------------- 1 file changed, 73 insertions(+), 40 deletions(-) diff --git a/cmd/lncli/commands.go b/cmd/lncli/commands.go index 53abbc7c..31e6ec4f 100644 --- a/cmd/lncli/commands.go +++ b/cmd/lncli/commands.go @@ -91,6 +91,7 @@ func actionDecorator(f func(*cli.Context) error) func(*cli.Context) error { var newAddressCommand = cli.Command{ Name: "newaddress", + Category: "Wallet", Usage: "Generates a new address.", ArgsUsage: "address-type", Description: ` @@ -133,6 +134,7 @@ func newAddress(ctx *cli.Context) error { var sendCoinsCommand = cli.Command{ Name: "sendcoins", + Category: "On-chain", Usage: "Send bitcoin on-chain to an address", ArgsUsage: "addr amt", Description: ` @@ -231,6 +233,7 @@ func sendCoins(ctx *cli.Context) error { var sendManyCommand = cli.Command{ Name: "sendmany", + Category: "On-chain", Usage: "Send bitcoin on-chain to multiple addresses.", ArgsUsage: "send-json-string [--conf_target=N] [--sat_per_byte=P]", Description: ` @@ -288,6 +291,7 @@ func sendMany(ctx *cli.Context) error { var connectCommand = cli.Command{ Name: "connect", + Category: "Peers", Usage: "Connect to a remote lnd peer", ArgsUsage: "@host", Flags: []cli.Flag{ @@ -333,6 +337,7 @@ func connectPeer(ctx *cli.Context) error { var disconnectCommand = cli.Command{ Name: "disconnect", + Category: "Peers", Usage: "Disconnect a remote lnd peer identified by public key", ArgsUsage: "", Flags: []cli.Flag{ @@ -375,8 +380,9 @@ func disconnectPeer(ctx *cli.Context) error { // TODO(roasbeef): change default number of confirmations var openChannelCommand = cli.Command{ - Name: "openchannel", - Usage: "Open a channel to a node or an existing peer.", + Name: "openchannel", + Category: "Channels", + Usage: "Open a channel to a node or an existing peer.", Description: ` Attempt to open a new channel to an existing peer with the key node-key optionally blocking until the channel is 'open'. @@ -610,8 +616,9 @@ func openChannel(ctx *cli.Context) error { // TODO(roasbeef): also allow short relative channel ID. var closeChannelCommand = cli.Command{ - Name: "closechannel", - Usage: "Close an existing channel.", + Name: "closechannel", + Category: "Channels", + Usage: "Close an existing channel.", Description: ` Close an existing channel. The channel can be closed either cooperatively, or unilaterally (--force). @@ -788,8 +795,9 @@ func executeChannelClose(client lnrpc.LightningClient, req *lnrpc.CloseChannelRe } var closeAllChannelsCommand = cli.Command{ - Name: "closeallchannels", - Usage: "Close all existing channels.", + Name: "closeallchannels", + Category: "Channels", + Usage: "Close all existing channels.", Description: ` Close all existing channels. @@ -999,9 +1007,10 @@ func promptForConfirmation(msg string) bool { } var listPeersCommand = cli.Command{ - Name: "listpeers", - Usage: "List all active, currently connected peers.", - Action: actionDecorator(listPeers), + Name: "listpeers", + Category: "Peers", + Usage: "List all active, currently connected peers.", + Action: actionDecorator(listPeers), } func listPeers(ctx *cli.Context) error { @@ -1020,7 +1029,8 @@ func listPeers(ctx *cli.Context) error { } var createCommand = cli.Command{ - Name: "create", + Name: "create", + Category: "Wallet", Description: ` The create command is used to initialize an lnd wallet from scratch for the very first time. This is interactive command with one required @@ -1292,7 +1302,8 @@ mnemonicCheck: } var unlockCommand = cli.Command{ - Name: "unlock", + Name: "unlock", + Category: "Wallet", Description: ` The unlock command is used to decrypt lnd's wallet state in order to start up. This command MUST be run after booting up lnd before it's @@ -1356,9 +1367,10 @@ func unlock(ctx *cli.Context) error { } var walletBalanceCommand = cli.Command{ - Name: "walletbalance", - Usage: "Compute and display the wallet's current balance", - Action: actionDecorator(walletBalance), + Name: "walletbalance", + Category: "Wallet", + Usage: "Compute and display the wallet's current balance", + Action: actionDecorator(walletBalance), } func walletBalance(ctx *cli.Context) error { @@ -1377,9 +1389,10 @@ func walletBalance(ctx *cli.Context) error { } var channelBalanceCommand = cli.Command{ - Name: "channelbalance", - Usage: "Returns the sum of the total available channel balance across all open channels", - Action: actionDecorator(channelBalance), + Name: "channelbalance", + Category: "Channels", + Usage: "Returns the sum of the total available channel balance across all open channels", + Action: actionDecorator(channelBalance), } func channelBalance(ctx *cli.Context) error { @@ -1419,9 +1432,10 @@ func getInfo(ctx *cli.Context) error { } var pendingChannelsCommand = cli.Command{ - Name: "pendingchannels", - Usage: "Display information pertaining to pending channels", - Action: actionDecorator(pendingChannels), + Name: "pendingchannels", + Category: "Channels", + Usage: "Display information pertaining to pending channels", + Action: actionDecorator(pendingChannels), } func pendingChannels(ctx *cli.Context) error { @@ -1441,8 +1455,9 @@ func pendingChannels(ctx *cli.Context) error { } var listChannelsCommand = cli.Command{ - Name: "listchannels", - Usage: "List all open channels", + Name: "listchannels", + Category: "Channels", + Usage: "List all open channels", Flags: []cli.Flag{ cli.BoolFlag{ Name: "active_only", @@ -1489,8 +1504,9 @@ func listChannels(ctx *cli.Context) error { } var sendPaymentCommand = cli.Command{ - Name: "sendpayment", - Usage: "Send a payment over lightning", + Name: "sendpayment", + Category: "Payments", + Usage: "Send a payment over lightning", Description: ` Send a payment over Lightning. One can either specify the full parameters of the payment, or just use a payment request which encodes @@ -1672,6 +1688,7 @@ func sendPaymentRequest(ctx *cli.Context, req *lnrpc.SendRequest) error { var payInvoiceCommand = cli.Command{ Name: "payinvoice", + Category: "Payments", Usage: "Pay an invoice over lightning", ArgsUsage: "pay_req", Flags: []cli.Flag{ @@ -1711,8 +1728,9 @@ func payInvoice(ctx *cli.Context) error { } var addInvoiceCommand = cli.Command{ - Name: "addinvoice", - Usage: "Add a new invoice.", + Name: "addinvoice", + Category: "Payments", + Usage: "Add a new invoice.", Description: ` Add a new invoice, expressing intent for a future payment. @@ -1845,6 +1863,7 @@ func addInvoice(ctx *cli.Context) error { var lookupInvoiceCommand = cli.Command{ Name: "lookupinvoice", + Category: "Payments", Usage: "Lookup an existing invoice by its payment hash.", ArgsUsage: "rhash", Flags: []cli.Flag{ @@ -1894,8 +1913,9 @@ func lookupInvoice(ctx *cli.Context) error { } var listInvoicesCommand = cli.Command{ - Name: "listinvoices", - Usage: "List all invoices currently stored.", + Name: "listinvoices", + Category: "Payments", + Usage: "List all invoices currently stored.", Flags: []cli.Flag{ cli.BoolFlag{ Name: "pending_only", @@ -1930,7 +1950,8 @@ func listInvoices(ctx *cli.Context) error { } var describeGraphCommand = cli.Command{ - Name: "describegraph", + Name: "describegraph", + Category: "Peers", Description: "Prints a human readable version of the known channel " + "graph from the PoV of the node", Usage: "Describe the network graph", @@ -2125,9 +2146,10 @@ func drawChannelGraph(graph *lnrpc.ChannelGraph) error { } var listPaymentsCommand = cli.Command{ - Name: "listpayments", - Usage: "List all outgoing payments", - Action: actionDecorator(listPayments), + Name: "listpayments", + Category: "Payments", + Usage: "List all outgoing payments", + Action: actionDecorator(listPayments), } func listPayments(ctx *cli.Context) error { @@ -2146,8 +2168,9 @@ func listPayments(ctx *cli.Context) error { } var getChanInfoCommand = cli.Command{ - Name: "getchaninfo", - Usage: "Get the state of a channel", + Name: "getchaninfo", + Category: "Channels", + Usage: "Get the state of a channel", Description: "Prints out the latest authenticated state for a " + "particular channel", ArgsUsage: "chan_id", @@ -2193,8 +2216,9 @@ func getChanInfo(ctx *cli.Context) error { } var getNodeInfoCommand = cli.Command{ - Name: "getnodeinfo", - Usage: "Get information on a specific node.", + Name: "getnodeinfo", + Category: "Peers", + Usage: "Get information on a specific node.", Description: "Prints out the latest authenticated node state for an " + "advertised node", Flags: []cli.Flag{ @@ -2239,6 +2263,7 @@ func getNodeInfo(ctx *cli.Context) error { var queryRoutesCommand = cli.Command{ Name: "queryroutes", + Category: "Payments", Usage: "Query a route to a destination.", Description: "Queries the channel router for a potential path to the destination that has sufficient flow for the amount including fees", ArgsUsage: "dest amt", @@ -2312,8 +2337,9 @@ func queryRoutes(ctx *cli.Context) error { } var getNetworkInfoCommand = cli.Command{ - Name: "getnetworkinfo", - Usage: "Getnetworkinfo", + Name: "getnetworkinfo", + Category: "Channels", + Usage: "Getnetworkinfo", Description: "Returns a set of statistics pertaining to the known channel " + "graph", Action: actionDecorator(getNetworkInfo), @@ -2375,6 +2401,7 @@ func debugLevel(ctx *cli.Context) error { var decodePayReqCommand = cli.Command{ Name: "decodepayreq", + Category: "Payments", Usage: "Decode a payment request.", Description: "Decode the passed payment request revealing the destination, payment hash and value of the payment request", ArgsUsage: "pay_req", @@ -2416,6 +2443,7 @@ func decodePayReq(ctx *cli.Context) error { var listChainTxnsCommand = cli.Command{ Name: "listchaintxns", + Category: "On-chain", Usage: "List transactions from the wallet.", Description: "List all transactions an address of the wallet was involved in.", Action: actionDecorator(listChainTxns), @@ -2460,6 +2488,7 @@ func stopDaemon(ctx *cli.Context) error { var signMessageCommand = cli.Command{ Name: "signmessage", + Category: "Wallet", Usage: "Sign a message with the node's private key", ArgsUsage: "msg", Description: ` @@ -2503,6 +2532,7 @@ func signMessage(ctx *cli.Context) error { var verifyMessageCommand = cli.Command{ Name: "verifymessage", + Category: "Wallet", Usage: "Verify a message signed with the signature", ArgsUsage: "msg signature", Description: ` @@ -2566,8 +2596,9 @@ func verifyMessage(ctx *cli.Context) error { } var feeReportCommand = cli.Command{ - Name: "feereport", - Usage: "Display the current fee policies of all active channels", + Name: "feereport", + Category: "Channels", + Usage: "Display the current fee policies of all active channels", Description: ` Returns the current fee policies of all active channels. Fee policies can be updated using the updatechanpolicy command.`, @@ -2591,6 +2622,7 @@ func feeReport(ctx *cli.Context) error { var updateChannelPolicyCommand = cli.Command{ Name: "updatechanpolicy", + Category: "Channels", Usage: "Update the channel policy for all channels, or a single channel", ArgsUsage: "base_fee_msat fee_rate time_lock_delta [channel_point]", Description: ` @@ -2740,6 +2772,7 @@ func updateChannelPolicy(ctx *cli.Context) error { var forwardingHistoryCommand = cli.Command{ Name: "fwdinghistory", + Category: "Payments", Usage: "Query the history of all forwarded htlcs", ArgsUsage: "start_time [end_time] [index_offset] [max_events]", Description: ` From 80852601dbd2b84c257a1b52a7f13518ed8a6091 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Thu, 3 May 2018 11:49:09 +0300 Subject: [PATCH 2/2] lncli: group startup commands, make full sentences --- cmd/lncli/commands.go | 53 +++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/cmd/lncli/commands.go b/cmd/lncli/commands.go index 31e6ec4f..960bb153 100644 --- a/cmd/lncli/commands.go +++ b/cmd/lncli/commands.go @@ -135,7 +135,7 @@ func newAddress(ctx *cli.Context) error { var sendCoinsCommand = cli.Command{ Name: "sendcoins", Category: "On-chain", - Usage: "Send bitcoin on-chain to an address", + Usage: "Send bitcoin on-chain to an address.", ArgsUsage: "addr amt", Description: ` Send amt coins in satoshis to the BASE58 encoded bitcoin address addr. @@ -292,7 +292,7 @@ func sendMany(ctx *cli.Context) error { var connectCommand = cli.Command{ Name: "connect", Category: "Peers", - Usage: "Connect to a remote lnd peer", + Usage: "Connect to a remote lnd peer.", ArgsUsage: "@host", Flags: []cli.Flag{ cli.BoolFlag{ @@ -338,7 +338,7 @@ func connectPeer(ctx *cli.Context) error { var disconnectCommand = cli.Command{ Name: "disconnect", Category: "Peers", - Usage: "Disconnect a remote lnd peer identified by public key", + Usage: "Disconnect a remote lnd peer identified by public key.", ArgsUsage: "", Flags: []cli.Flag{ cli.StringFlag{ @@ -1030,7 +1030,8 @@ func listPeers(ctx *cli.Context) error { var createCommand = cli.Command{ Name: "create", - Category: "Wallet", + Category: "Startup", + Usage: "Initialize a wallet when starting lnd for the first time.", Description: ` The create command is used to initialize an lnd wallet from scratch for the very first time. This is interactive command with one required @@ -1303,7 +1304,8 @@ mnemonicCheck: var unlockCommand = cli.Command{ Name: "unlock", - Category: "Wallet", + Category: "Startup", + Usage: "Unlock an encrypted wallet at startup.", Description: ` The unlock command is used to decrypt lnd's wallet state in order to start up. This command MUST be run after booting up lnd before it's @@ -1369,7 +1371,7 @@ func unlock(ctx *cli.Context) error { var walletBalanceCommand = cli.Command{ Name: "walletbalance", Category: "Wallet", - Usage: "Compute and display the wallet's current balance", + Usage: "Compute and display the wallet's current balance.", Action: actionDecorator(walletBalance), } @@ -1391,7 +1393,8 @@ func walletBalance(ctx *cli.Context) error { var channelBalanceCommand = cli.Command{ Name: "channelbalance", Category: "Channels", - Usage: "Returns the sum of the total available channel balance across all open channels", + Usage: "Returns the sum of the total available channel balance across " + + "all open channels.", Action: actionDecorator(channelBalance), } @@ -1412,7 +1415,7 @@ func channelBalance(ctx *cli.Context) error { var getInfoCommand = cli.Command{ Name: "getinfo", - Usage: "Returns basic information related to the active daemon", + Usage: "Returns basic information related to the active daemon.", Action: actionDecorator(getInfo), } @@ -1434,7 +1437,7 @@ func getInfo(ctx *cli.Context) error { var pendingChannelsCommand = cli.Command{ Name: "pendingchannels", Category: "Channels", - Usage: "Display information pertaining to pending channels", + Usage: "Display information pertaining to pending channels.", Action: actionDecorator(pendingChannels), } @@ -1457,7 +1460,7 @@ func pendingChannels(ctx *cli.Context) error { var listChannelsCommand = cli.Command{ Name: "listchannels", Category: "Channels", - Usage: "List all open channels", + Usage: "List all open channels.", Flags: []cli.Flag{ cli.BoolFlag{ Name: "active_only", @@ -1506,7 +1509,7 @@ func listChannels(ctx *cli.Context) error { var sendPaymentCommand = cli.Command{ Name: "sendpayment", Category: "Payments", - Usage: "Send a payment over lightning", + Usage: "Send a payment over lightning.", Description: ` Send a payment over Lightning. One can either specify the full parameters of the payment, or just use a payment request which encodes @@ -1689,7 +1692,7 @@ func sendPaymentRequest(ctx *cli.Context, req *lnrpc.SendRequest) error { var payInvoiceCommand = cli.Command{ Name: "payinvoice", Category: "Payments", - Usage: "Pay an invoice over lightning", + Usage: "Pay an invoice over lightning.", ArgsUsage: "pay_req", Flags: []cli.Flag{ cli.StringFlag{ @@ -1954,7 +1957,7 @@ var describeGraphCommand = cli.Command{ Category: "Peers", Description: "Prints a human readable version of the known channel " + "graph from the PoV of the node", - Usage: "Describe the network graph", + Usage: "Describe the network graph.", Flags: []cli.Flag{ cli.BoolFlag{ Name: "render", @@ -2148,7 +2151,7 @@ func drawChannelGraph(graph *lnrpc.ChannelGraph) error { var listPaymentsCommand = cli.Command{ Name: "listpayments", Category: "Payments", - Usage: "List all outgoing payments", + Usage: "List all outgoing payments.", Action: actionDecorator(listPayments), } @@ -2170,7 +2173,7 @@ func listPayments(ctx *cli.Context) error { var getChanInfoCommand = cli.Command{ Name: "getchaninfo", Category: "Channels", - Usage: "Get the state of a channel", + Usage: "Get the state of a channel.", Description: "Prints out the latest authenticated state for a " + "particular channel", ArgsUsage: "chan_id", @@ -2339,9 +2342,10 @@ func queryRoutes(ctx *cli.Context) error { var getNetworkInfoCommand = cli.Command{ Name: "getnetworkinfo", Category: "Channels", - Usage: "Getnetworkinfo", - Description: "Returns a set of statistics pertaining to the known channel " + - "graph", + Usage: "Get statistical information about the current " + + "state of the network.", + Description: "Returns a set of statistics pertaining to the known " + + "channel graph", Action: actionDecorator(getNetworkInfo), } @@ -2489,7 +2493,7 @@ func stopDaemon(ctx *cli.Context) error { var signMessageCommand = cli.Command{ Name: "signmessage", Category: "Wallet", - Usage: "Sign a message with the node's private key", + Usage: "Sign a message with the node's private key.", ArgsUsage: "msg", Description: ` Sign msg with the resident node's private key. @@ -2533,7 +2537,7 @@ func signMessage(ctx *cli.Context) error { var verifyMessageCommand = cli.Command{ Name: "verifymessage", Category: "Wallet", - Usage: "Verify a message signed with the signature", + Usage: "Verify a message signed with the signature.", ArgsUsage: "msg signature", Description: ` Verify that the message was signed with a properly-formed signature @@ -2598,7 +2602,7 @@ func verifyMessage(ctx *cli.Context) error { var feeReportCommand = cli.Command{ Name: "feereport", Category: "Channels", - Usage: "Display the current fee policies of all active channels", + Usage: "Display the current fee policies of all active channels.", Description: ` Returns the current fee policies of all active channels. Fee policies can be updated using the updatechanpolicy command.`, @@ -2623,7 +2627,8 @@ func feeReport(ctx *cli.Context) error { var updateChannelPolicyCommand = cli.Command{ Name: "updatechanpolicy", Category: "Channels", - Usage: "Update the channel policy for all channels, or a single channel", + Usage: "Update the channel policy for all channels, or a single " + + "channel.", ArgsUsage: "base_fee_msat fee_rate time_lock_delta [channel_point]", Description: ` Updates the channel policy for all channels, or just a particular channel @@ -2773,10 +2778,10 @@ func updateChannelPolicy(ctx *cli.Context) error { var forwardingHistoryCommand = cli.Command{ Name: "fwdinghistory", Category: "Payments", - Usage: "Query the history of all forwarded htlcs", + Usage: "Query the history of all forwarded HTLCs.", ArgsUsage: "start_time [end_time] [index_offset] [max_events]", Description: ` - Query the htlc switch's internal forwarding log for all completed + Query the HTLC switch's internal forwarding log for all completed payment circuits (HTLCs) over a particular time range (--start_time and --end_time). The start and end times are meant to be expressed in seconds since the Unix epoch. If a start and end time aren't provided,