Skip to content

Commit

Permalink
An improvement to the litcli help messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
nonfungible-human committed Oct 26, 2023
1 parent 6f4c473 commit 53f54af
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 97 deletions.
51 changes: 24 additions & 27 deletions cmd/litcli/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var accountsCommands = []cli.Command{
{
Name: "accounts",
ShortName: "a",
Usage: "manage accounts",
Usage: "Manage accounts",
Category: "Accounts",
Subcommands: []cli.Command{
createAccountCommand,
Expand All @@ -31,6 +31,7 @@ var accountsCommands = []cli.Command{
accountInfoCommand,
removeAccountCommand,
},
Description: "Manage accounts.",
},
}

Expand All @@ -50,27 +51,26 @@ var createAccountCommand = cli.Command{
Accounts only assert a maximum amount spendable. Having a certain
account balance does not guarantee that the node has the channel
liquidity to actually spend that amount.
`,
liquidity to actually spend that amount.`,
Flags: []cli.Flag{
cli.Uint64Flag{
Name: "balance",
Usage: "the initial balance of the account",
Usage: "The initial balance of the account.",
},
cli.Int64Flag{
Name: "expiration_date",
Usage: "the expiration date of the account expressed " +
Usage: "The expiration date of the account expressed " +
"in seconds since the unix epoch. 0 means " +
"it does not expire",
"it does not expire.",
},
cli.StringFlag{
Name: "save_to",
Usage: "store the account macaroon created for the " +
"account to the given file",
Usage: "Store the account macaroon created for the " +
"account to the given file.",
},
cli.StringFlag{
Name: labelName,
Usage: "(optional) the unique label of the account",
Usage: "(optional) The unique label of the account.",
},
},
Action: createAccount,
Expand Down Expand Up @@ -154,29 +154,28 @@ var updateAccountCommand = cli.Command{
ArgsUsage: "[id | label] new_balance [new_expiration_date] [--save_to=]",
Description: `
Updates an existing off-chain account and sets either a new balance or
new expiration date or both.
`,
new expiration date or both.`,
Flags: []cli.Flag{
cli.StringFlag{
Name: idName,
Usage: "the ID of the account to update",
Usage: "The ID of the account to update.",
},
cli.StringFlag{
Name: labelName,
Usage: "(optional) the unique label of the account",
Usage: "(optional) The unique label of the account.",
},
cli.Int64Flag{
Name: "new_balance",
Usage: "the new balance of the account; -1 means do " +
"not update the balance",
Usage: "The new balance of the account; -1 means do " +
"not update the balance.",
Value: -1,
},
cli.Int64Flag{
Name: "new_expiration_date",
Usage: "the new expiration date of the account " +
Usage: "The new expiration date of the account " +
"expressed in seconds since the unix epoch; " +
"-1 means do not update the expiration date; " +
"0 means it does not expire",
"0 means it does not expire.",
Value: -1,
},
},
Expand Down Expand Up @@ -243,7 +242,7 @@ func updateAccount(ctx *cli.Context) error {
var listAccountsCommand = cli.Command{
Name: "list",
ShortName: "l",
Usage: "Lists all off-chain accounts.",
Usage: "List all off-chain accounts.",
Description: `
Returns all accounts that are currently stored in the account
database.
Expand Down Expand Up @@ -276,16 +275,15 @@ var accountInfoCommand = cli.Command{
Usage: "Show information about a single off-chain account.",
ArgsUsage: "[id | label]",
Description: `
Returns a single account entry from the account database.
`,
Returns a single account entry from the account database.`,
Flags: []cli.Flag{
cli.StringFlag{
Name: idName,
Usage: "the ID of the account",
Usage: "The ID of the account.",
},
cli.StringFlag{
Name: labelName,
Usage: "(optional) the unique label of the account",
Usage: "(optional) The unique label of the account.",
},
},
Action: accountInfo,
Expand Down Expand Up @@ -321,19 +319,18 @@ func accountInfo(ctx *cli.Context) error {
var removeAccountCommand = cli.Command{
Name: "remove",
ShortName: "r",
Usage: "Removes an off-chain account from the database.",
Usage: "Remove an off-chain account from the database.",
ArgsUsage: "[id | label]",
Description: `
Removes an account entry from the account database.
`,
Removes an account entry from the account database.`,
Flags: []cli.Flag{
cli.StringFlag{
Name: idName,
Usage: "the ID of the account",
Usage: "The ID of the account.",
},
cli.StringFlag{
Name: labelName,
Usage: "(optional) the unique label of the account",
Usage: "(optional) The unique label of the account.",
},
},
Action: removeAccount,
Expand Down
11 changes: 6 additions & 5 deletions cmd/litcli/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
var listActionsCommand = cli.Command{
Name: "actions",
Usage: "List actions performed on the Litd server",
Category: "Actions",
Action: listActions,
Flags: []cli.Flag{
cli.StringFlag{
Expand Down Expand Up @@ -53,21 +54,21 @@ var listActionsCommand = cli.Command{
Name: "state",
Usage: "The action state to filter on. If not set, " +
"then actions of any state will be returned. " +
"Options include: 'pending', 'done' and 'error",
"Options include: 'pending', 'done' and 'error'.",
},
cli.Uint64Flag{
Name: "index_offset",
Usage: "The index of an action that will be used as " +
"either the start a query to determine which " +
"actions should be returned in the response",
"the start of a query to determine which " +
"actions should be returned in the response.",
},
cli.Uint64Flag{
Name: "max_num_actions",
Usage: "The max number of actions to return",
Usage: "The max number of actions to return.",
},
cli.BoolFlag{
Name: "oldest_first",
Usage: "Tf set, actions succeeding the index_offset " +
Usage: "if set, actions succeeding the index_offset " +
"will be returned",
},
cli.BoolFlag{
Expand Down
26 changes: 11 additions & 15 deletions cmd/litcli/autopilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ import (

var autopilotCommands = cli.Command{
Name: "autopilot",
Usage: "manage autopilot sessions",
Usage: "Manage autopilot sessions",
Category: "Autopilot",
Subcommands: []cli.Command{
listAutopilotFeaturesCmd,
addAutopilotSessionCmd,
revokeAutopilotSessionCmd,
listAutopilotSessionsCmd,
},
Description: "Manage autopilot sessions.",
}

var listAutopilotFeaturesCmd = cli.Command{
Name: "features",
ShortName: "f",
Usage: "List available Autopilot features.",
Description: `
List available Autopilot features.
Description: `List available Autopilot features.
`,
Action: listFeatures,
}
Expand All @@ -57,22 +57,22 @@ var addAutopilotSessionCmd = cli.Command{
},
cli.StringFlag{
Name: "channel-restrict-list",
Usage: "list of channel IDs that the " +
Usage: "List of channel IDs that the " +
"Autopilot server should not " +
"perform actions on. In the " +
"form of: chanID1,chanID2,...",
},
cli.StringFlag{
Name: "peer-restrict-list",
Usage: "list of peer IDs that the " +
Usage: "List of peer IDs that the " +
"Autopilot server should not " +
"perform actions on. In the " +
"form of: peerID1,peerID2,...",
},
cli.StringFlag{
Name: "group_id",
Usage: "The hex encoded group ID of the session " +
"group to link this one to",
"group to link this one to.",
},
cli.StringSliceFlag{
Name: "feature-config",
Expand All @@ -81,7 +81,7 @@ var addAutopilotSessionCmd = cli.Command{
`"option1":"parameter1",` +
`"option2":"parameter2",...}. An empty ` +
`configuration is allowed with {} to use the ` +
`default configuration`,
`default configuration.`,
},
},
}
Expand All @@ -90,15 +90,13 @@ var revokeAutopilotSessionCmd = cli.Command{
Name: "revoke",
ShortName: "r",
Usage: "Revoke an Autopilot session.",
Description: `
Revoke an active Autopilot session.
`,
Description: "Revoke an active Autopilot session.",
Action: revokeAutopilotSession,
Flags: []cli.Flag{
cli.StringFlag{
Name: "localpubkey",
Usage: "local pubkey of the " +
"session to revoke",
Usage: "Local pubkey of the " +
"session to revoke.",
Required: true,
},
},
Expand All @@ -108,9 +106,7 @@ var listAutopilotSessionsCmd = cli.Command{
Name: "list",
ShortName: "l",
Usage: "List all Autopilot sessions.",
Description: `
List all Autopilot sessions.
`,
Description: "List all Autopilot sessions.\n",
Action: listAutopilotSessions,
}

Expand Down
19 changes: 9 additions & 10 deletions cmd/litcli/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import (
// helperCommands are commands that do not require a connection to LiTd to
// return a response.
var helperCommands = cli.Command{
Name: "helper",
Usage: "helper commands",
Category: "Helper",
Name: "helper",
Usage: "Helper commands",
Description: "Helper commands.",
Category: "Helper",
Subcommands: []cli.Command{
generateSuperMacRootIDCmd,
isSuperMacaroonCmd,
Expand All @@ -28,11 +29,10 @@ var helperCommands = cli.Command{
var generateSuperMacRootIDCmd = cli.Command{
Name: "supermacrootkey",
Usage: "Generate a valid super macaroon root key ID from scratch " +
"or from a given root key ID suffix",
"or from a given root key ID suffix.",
Description: `
This command can be used to generate a valid super macaroon root key ID
from scratch or from a given root key ID suffix.
`,
from scratch or from a given root key ID suffix.`,
Action: superMacRootKey,
Flags: []cli.Flag{
cli.StringFlag{
Expand Down Expand Up @@ -81,16 +81,15 @@ func superMacRootKey(ctx *cli.Context) error {
// a macaroon is a super macaroon.
var isSuperMacaroonCmd = cli.Command{
Name: "issupermacaroon",
Usage: "Prints 'true' if the given macaroon is a super macaroon",
Usage: "Prints 'true' if the given macaroon is a super macaroon.",
Description: `
This command can be used to verify if a macaroon is considered a
super macaroon.
`,
super macaroon.`,
Action: isSuperMacaroon,
Flags: []cli.Flag{
cli.StringFlag{
Name: "mac",
Usage: "The hex-encoded macaroon",
Usage: "The hex-encoded macaroon.",
Required: true,
},
},
Expand Down
15 changes: 10 additions & 5 deletions cmd/litcli/privacy_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var privacyMapCommands = cli.Command{
Name: "privacy",
ShortName: "p",
Usage: "Access the real-pseudo string pairs of the " +
"privacy mapper",
"privacy mapper.",
Category: "Privacy",
Flags: []cli.Flag{
cli.StringFlag{
Expand All @@ -40,17 +40,22 @@ var privacyMapCommands = cli.Command{
privacyMapConvertStrCommand,
privacyMapConvertUint64Command,
},
Description: `Access the real-pseudo string pairs of the privacy mapper.
To improve privacy around data sharing, channel ids, channel points and node
pubkeys are obfuscated by litd through a system called the Privacy Mapper.
The Privacy Mapper can convert both strings and uint64 to the pseudo
counter part and back.`,
}

var privacyMapConvertStrCommand = cli.Command{
Name: "str",
ShortName: "s",
Usage: "convert a string to its real or pseudo counter part",
Usage: "Convert a string to its real or pseudo counter part.",
Action: privacyMapConvertStr,
Flags: []cli.Flag{
cli.StringFlag{
Name: "input",
Usage: "the string to convert",
Usage: "The string to convert.",
Required: true,
},
},
Expand Down Expand Up @@ -99,12 +104,12 @@ func privacyMapConvertStr(ctx *cli.Context) error {
var privacyMapConvertUint64Command = cli.Command{
Name: "uint64",
ShortName: "u",
Usage: "convert a uint64 to its real or pseudo counter part",
Usage: "Convert a uint64 to its real or pseudo counter part.",
Action: privacyMapConvertUint64,
Flags: []cli.Flag{
cli.Uint64Flag{
Name: "input",
Usage: "the uint64 to convert",
Usage: "The uint64 to convert.",
Required: true,
},
},
Expand Down
Loading

0 comments on commit 53f54af

Please sign in to comment.