Automatically generate markdown pages from bor CLI

Adding a script that can automatically generate markdown pages from bor
CLI, so we can avoid copy-pasting helper strings whenever a flag is created,
deleted, or modified.

CLI docs could be generated with command `make docs`.
This commit is contained in:
Jerry 2022-04-22 11:44:35 -07:00 committed by Victor Castell
parent 597037df30
commit a131e427f6
44 changed files with 740 additions and 217 deletions

View file

@ -2,7 +2,11 @@
# with Go source code. If you know what GOPATH is then you probably # with Go source code. If you know what GOPATH is then you probably
# don't need to bother with make. # don't need to bother with make.
.PHONY: geth android ios evm all test clean .PHONY: geth android ios geth-cross evm all test clean docs
.PHONY: geth-linux geth-linux-386 geth-linux-amd64 geth-linux-mips64 geth-linux-mips64le
.PHONY: geth-linux-arm geth-linux-arm-5 geth-linux-arm-6 geth-linux-arm-7 geth-linux-arm64
.PHONY: geth-darwin geth-darwin-386 geth-darwin-amd64
.PHONY: geth-windows geth-windows-386 geth-windows-amd64
GOBIN = ./build/bin GOBIN = ./build/bin
GO ?= latest GO ?= latest
@ -43,6 +47,9 @@ test:
lint: ## Run linters. lint: ## Run linters.
$(GORUN) build/ci.go lint $(GORUN) build/ci.go lint
docs:
$(GORUN) cmd/clidoc/main.go -d ./docs/cli
clean: clean:
env GO111MODULE=on go clean -cache env GO111MODULE=on go clean -cache
rm -fr build/_workspace/pkg/ $(GOBIN)/* rm -fr build/_workspace/pkg/ $(GOBIN)/*

71
cmd/clidoc/main.go Normal file
View file

@ -0,0 +1,71 @@
package main
import (
"flag"
"log"
"os"
"path/filepath"
"sort"
"strings"
"github.com/ethereum/go-ethereum/internal/cli"
)
const (
DefaultDir string = "./docs/cli"
DefaultMainPage string = "README.md"
)
func main() {
commands := cli.Commands()
dest := flag.String("d", DefaultDir, "Destination directory where the docs will be generated")
flag.Parse()
dirPath := filepath.Join(".", *dest)
if err := os.MkdirAll(dirPath, os.ModePerm); err != nil {
log.Fatalln("Failed to create directory.", err)
}
mainPage := []string{
"# Bor command line interface",
"## Commands",
}
keys := make([]string, len(commands))
i := 0
for k := range commands {
keys[i] = k
i++
}
sort.Strings(keys)
for _, name := range keys {
cmd, err := commands[name]()
if err != nil {
log.Fatalf("Error occurred when inspecting bor command %s: %s", name, err)
}
fileName := strings.ReplaceAll(name, " ", "_") + ".md"
overwriteFile(filepath.Join(dirPath, fileName), cmd.MarkDown())
mainPage = append(mainPage, "- [```"+name+"```](./"+fileName+")")
}
overwriteFile(filepath.Join(dirPath, DefaultMainPage), strings.Join(mainPage, "\n\n"))
os.Exit(0)
}
func overwriteFile(filePath string, text string) {
log.Printf("Writing to page: %s\n", filePath)
f, err := os.Create(filePath)
if err != nil {
log.Fatalln(err)
}
f.WriteString(text)
if err := f.Close(); err != nil {
log.Fatalln(err)
}
}

View file

@ -1,24 +1,27 @@
# Bor command line interface
# Command line interface
## Commands ## Commands
- [```server```](./server.md)
- [```debug```](./debug.md)
- [```account```](./account.md) - [```account```](./account.md)
- [```account new```](./account_new.md) - [```account import```](./account_import.md)
- [```account list```](./account_list.md) - [```account list```](./account_list.md)
- [```account import```](./account_import.md) - [```account new```](./account_new.md)
- [```attach```](./attach.md)
- [```chain```](./chain.md) - [```chain```](./chain.md)
- [```chain sethead```](./chain_sethead.md) - [```chain sethead```](./chain_sethead.md)
- [```chain watch```](./chain_watch.md)
- [```debug```](./debug.md)
- [```fingerprint```](./fingerprint.md)
- [```peers```](./peers.md) - [```peers```](./peers.md)
- [```peers add```](./peers_add.md) - [```peers add```](./peers_add.md)
@ -29,8 +32,8 @@
- [```peers status```](./peers_status.md) - [```peers status```](./peers_status.md)
- [```server```](./server.md)
- [```status```](./status.md) - [```status```](./status.md)
- [```chain watch```](./chain_watch.md) - [```version```](./version.md)
- [```version```](./version.md)

View file

@ -1,4 +1,3 @@
# Account # Account
The ```account``` command groups actions to interact with accounts: The ```account``` command groups actions to interact with accounts:
@ -7,4 +6,4 @@ The ```account``` command groups actions to interact with accounts:
- [```account list```](./account_list.md): List the wallets in the Bor client. - [```account list```](./account_list.md): List the wallets in the Bor client.
- [```account import```](./account_import.md): Import an account to the Bor client. - [```account import```](./account_import.md): Import an account to the Bor client.

View file

@ -1,4 +1,9 @@
# Account import # Account import
The ```account import``` command imports an account in Json format to the Bor data directory. The ```account import``` command imports an account in Json format to the Bor data directory.
## Options
- ```datadir```: Path of the data directory to store information
- ```keystore```: Path of the data directory to store information

View file

@ -1,4 +1,9 @@
# Account list # Account list
The ```account list``` command lists all the accounts in the Bor data directory. The `account list` command lists all the accounts in the Bor data directory.
## Options
- ```datadir```: Path of the data directory to store information
- ```keystore```: Path of the data directory to store information

View file

@ -1,4 +1,9 @@
# Account new # Account new
The ```account new``` command creates a new local account file on the Bor data directory. Bor should not be running to execute this command. The `account new` command creates a new local account file on the Bor data directory. Bor should not be running to execute this command.
## Options
- ```datadir```: Path of the data directory to store information
- ```keystore```: Path of the data directory to store information

11
docs/cli/attach.md Normal file
View file

@ -0,0 +1,11 @@
# Attach
Connect to remote Bor IPC console.
## Options
- ```exec```: Command to run in remote console
- ```preload```: Comma separated list of JavaScript files to preload into the console
- ```jspath```: JavaScript root path for `loadScript`

View file

@ -1,6 +1,7 @@
# Chain # Chain
The ```chain``` command groups actions to interact with the blockchain in the client: The ```chain``` command groups actions to interact with the blockchain in the client:
- [```chain sethead```](./chain_sethead.md): Set the current chain to a certain block. - [```chain sethead```](./chain_sethead.md): Set the current chain to a certain block.
- [```chain watch```](./chain_watch.md): Watch the chainHead, reorg and fork events in real-time.

View file

@ -1,4 +1,3 @@
# Chain sethead # Chain sethead
The ```chain sethead <number>``` command sets the current chain to a certain block. The ```chain sethead <number>``` command sets the current chain to a certain block.
@ -9,4 +8,6 @@ The ```chain sethead <number>``` command sets the current chain to a certain blo
## Options ## Options
- ```yes```: Force set head. - ```address```: Address of the grpc endpoint
- ```yes```: Force set head

View file

@ -1,3 +1,3 @@
# Chain watch # Chain watch
The ```chain watch``` command is used to view the chainHead, reorg and fork events in real-time. The ```chain watch``` command is used to view the chainHead, reorg and fork events in real-time.

View file

@ -1,13 +1,14 @@
# Debug # Debug
The ```bor debug``` command takes a debug dump of the running client. The ```bor debug``` command takes a debug dump of the running client.
## Options ## Options
- ```seconds```: Number of seconds to trace cpu and traces. - ```address```: Address of the grpc endpoint
- ```output```: Output directory for the data dump. - ```seconds```: seconds to trace
- ```output```: Output directory
## Examples ## Examples
@ -15,8 +16,8 @@ By default it creates a tar.gz file with the output:
``` ```
$ bor debug $ bor debug
Starting debugger... Starting debugger...
Created debug archive: bor-debug-2021-10-26-073819Z.tar.gz Created debug archive: bor-debug-2021-10-26-073819Z.tar.gz
``` ```
@ -27,4 +28,4 @@ $ bor debug --output data
Starting debugger... Starting debugger...
Created debug directory: data/bor-debug-2021-10-26-075437Z Created debug directory: data/bor-debug-2021-10-26-075437Z
``` ```

3
docs/cli/fingerprint.md Normal file
View file

@ -0,0 +1,3 @@
# Fingerprint
Display the system fingerprint

View file

@ -1,4 +1,3 @@
# Peers # Peers
The ```peers``` command groups actions to interact with peers: The ```peers``` command groups actions to interact with peers:
@ -9,4 +8,4 @@ The ```peers``` command groups actions to interact with peers:
- [```peers remove```](./peers_remove.md): Disconnects the local client from a connected peer if exists. - [```peers remove```](./peers_remove.md): Disconnects the local client from a connected peer if exists.
- [```peers status```](./peers_status.md): Display the status of a peer by its id. - [```peers status```](./peers_status.md): Display the status of a peer by its id.

View file

@ -1,8 +1,9 @@
# Peers add # Peers add
The ```peers add <enode>``` command joins the local client to another remote peer. The ```peers add <enode>``` command joins the local client to another remote peer.
## Arguments ## Options
- ```trusted```: Whether the peer is added as a trusted peer. - ```address```: Address of the grpc endpoint
- ```trusted```: Add the peer as a trusted

View file

@ -1,4 +1,7 @@
# Peers add
# Peers list
The ```peers list``` command lists the connected peers. The ```peers list``` command lists the connected peers.
## Options
- ```address```: Address of the grpc endpoint

View file

@ -1,4 +1,9 @@
# Peers remove # Peers remove
The ```peers remove <enode>``` command disconnects the local client from a connected peer if exists. The ```peers remove <enode>``` command disconnects the local client from a connected peer if exists.
## Options
- ```address```: Address of the grpc endpoint
- ```trusted```: Add the peer as a trusted

View file

@ -1,4 +1,7 @@
# Peers status # Peers status
The ```peers status <peer id>``` command displays the status of a peer by its id. The ```peers status <peer id>``` command displays the status of a peer by its id.
## Options
- ```address```: Address of the grpc endpoint

View file

@ -1,45 +1,178 @@
# Server # Server
The ```bor server``` command runs the Bor client. The ```bor server``` command runs the Bor client.
## General Options ## Options
- ```chain```: Name of the chain to sync (mainnet or mumbai). - ```chain```: Name of the chain to sync
- ```log-level```: Set log level for the server (info, warn, debug, trace). - ```name```: Name/Identity of the node
- ```datadir```: Path of the data directory to store information (defaults to $HOME). - ```log-level```: Set log level for the server
- ```config```: List of files that contain the configuration. - ```datadir```: Path of the data directory to store information
- ```syncmode```: Blockchain sync mode ("fast", "full", "snap" or "light"). - ```config```: File for the config file
- ```gcmode```: Blockchain garbage collection mode ("full", "archive"). - ```syncmode```: Blockchain sync mode ("fast", "full", or "snap")
- ```whitelist```: Comma separated block number-to-hash mappings to enforce (<number>=<hash>). - ```gcmode```: Blockchain garbage collection mode ("full", "archive")
- ```snapshot```: Enables snapshot-database mode (default = enable). - ```whitelist```: Comma separated block number-to-hash mappings to enforce (<number>=<hash>)
- ```bor.heimdall```: URL of Heimdall service. - ```no-snapshot```: Disables the snapshot-database mode (default = false)
- ```bor.withoutheimdall```: Run without Heimdall service (for testing purpose). - ```bor.heimdall```: URL of Heimdall service
- ```ethstats```: Reporting URL of a ethstats service (nodename:secret@host:port). - ```bor.withoutheimdall```: Run without Heimdall service (for testing purpose)
- ```gpo.blocks```: Number of recent blocks to check for gas prices. - ```ethstats```: Reporting URL of a ethstats service (nodename:secret@host:port)
- ```gpo.percentile```: Suggested gas price is the given percentile of a set of recent transaction gas prices. - ```gpo.blocks```: Number of recent blocks to check for gas prices
- ```gpo.maxprice```: Maximum gas price will be recommended by gpo. - ```gpo.percentile```: Suggested gas price is the given percentile of a set of recent transaction gas prices
- ```gpo.ignoreprice```: Gas price below which gpo will ignore transactions. - ```gpo.maxprice```: Maximum gas price will be recommended by gpo
- ```grpc.addr```: Address and port to bind the GRPC server. - ```gpo.ignoreprice```: Gas price below which gpo will ignore transactions
- ```grpc.addr```: Address and port to bind the GRPC server
- ```dev```: Enable developer mode with ephemeral proof-of-authority network and a pre-funded developer account, mining enabled
- ```dev.period```: Block period to use in developer mode (0 = mine only if transaction pending)
### Account Management Options
- ```unlock```: Comma separated list of accounts to unlock
- ```password```: Password file to use for non-interactive password input
- ```allow-insecure-unlock```: Allow insecure account unlocking when account-related RPCs are exposed by http
- ```lightkdf```: Reduce key-derivation RAM & CPU usage at some expense of KDF strength
### Cache Options
- ```cache```: Megabytes of memory allocated to internal caching (default = 4096 mainnet full node)
- ```cache.database```: Percentage of cache memory allowance to use for database io
- ```cache.trie```: Percentage of cache memory allowance to use for trie caching (default = 15% full mode, 30% archive mode)
- ```cache.trie.journal```: Disk journal directory for trie cache to survive node restarts
- ```cache.trie.rejournal```: Time interval to regenerate the trie cache journal
- ```cache.gc```: Percentage of cache memory allowance to use for trie pruning (default = 25% full mode, 0% archive mode)
- ```cache.snapshot```: Percentage of cache memory allowance to use for snapshot caching (default = 10% full mode, 20% archive mode)
- ```cache.noprefetch```: Disable heuristic state prefetch during block import (less CPU and disk IO, more time waiting for data)
- ```cache.preimages```: Enable recording the SHA3/keccak preimages of trie keys
- ```txlookuplimit```: Number of recent blocks to maintain transactions index for (default = about one year, 0 = entire chain)
### JsonRPC Options
- ```rpc.gascap```: Sets a cap on gas that can be used in eth_call/estimateGas (0=infinite)
- ```rpc.txfeecap```: Sets a cap on transaction fee (in ether) that can be sent via the RPC APIs (0 = no cap)
- ```ipcdisable```: Disable the IPC-RPC server
- ```ipcpath```: Filename for IPC socket/pipe within the datadir (explicit paths escape it)
- ```jsonrpc.corsdomain```: Comma separated list of domains from which to accept cross origin requests (browser enforced)
- ```jsonrpc.vhosts```: Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.
- ```http```: Enable the HTTP-RPC server
- ```http.addr```: HTTP-RPC server listening interface
- ```http.port```: HTTP-RPC server listening port
- ```http.rpcprefix```: HTTP path path prefix on which JSON-RPC is served. Use '/' to serve on all paths.
- ```http.modules```: API's offered over the HTTP-RPC interface
- ```ws```: Enable the WS-RPC server
- ```ws.addr```: WS-RPC server listening interface
- ```ws.port```: WS-RPC server listening port
- ```ws.rpcprefix```: HTTP path prefix on which JSON-RPC is served. Use '/' to serve on all paths.
- ```ws.modules```: API's offered over the WS-RPC interface
- ```graphql```: Enable GraphQL on the HTTP-RPC server. Note that GraphQL can only be started if an HTTP server is started as well.
### P2P Options
- ```bind```: Network binding address
- ```port```: Network listening port
- ```bootnodes```: Comma separated enode URLs for P2P discovery bootstrap
- ```maxpeers```: Maximum number of network peers (network disabled if set to 0)
- ```maxpendpeers```: Maximum number of pending connection attempts (defaults used if set to 0)
- ```nat```: NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>)
- ```nodiscover```: Disables the peer discovery mechanism (manual peer addition)
- ```v5disc```: Enables the experimental RLPx V5 (Topic Discovery) mechanism
### Sealer Options
- ```mine```: Enable mining
- ```miner.etherbase```: Public address for block mining rewards (default = first account)
- ```miner.extradata```: Block extra data set by the miner (default = client version)
- ```miner.gaslimit```: Target gas ceiling for mined blocks
- ```miner.gasprice```: Minimum gas price for mining a transaction
### Telemetry Options
- ```metrics```: Enable metrics collection and reporting
- ```metrics.expensive```: Enable expensive metrics collection and reporting
- ```metrics.influxdb```: Enable metrics export/push to an external InfluxDB database (v1)
- ```metrics.influxdb.endpoint```: InfluxDB API endpoint to report metrics to
- ```metrics.influxdb.database```: InfluxDB database name to push reported metrics to
- ```metrics.influxdb.username```: Username to authorize access to the database
- ```metrics.influxdb.password```: Password to authorize access to the database
- ```metrics.influxdb.tags```: Comma-separated InfluxDB tags (key/values) attached to all measurements
- ```metrics.prometheus-addr```: Address for Prometheus Server
- ```metrics.opencollector-endpoint```: OpenCollector Endpoint (host:port)
- ```metrics.influxdbv2```: Enable metrics export/push to an external InfluxDB v2 database
- ```metrics.influxdb.token```: Token to authorize access to the database (v2 only)
- ```metrics.influxdb.bucket```: InfluxDB bucket name to push reported metrics to (v2 only)
- ```metrics.influxdb.organization```: InfluxDB organization name (v2 only)
### Transaction Pool Options ### Transaction Pool Options
- ```txpool.locals```: Comma separated accounts to treat as locals (no flush, priority inclusion). - ```txpool.locals```: Comma separated accounts to treat as locals (no flush, priority inclusion)
- ```txpool.nolocals```: Disables price exemptions for locally submitted transactions - ```txpool.nolocals```: Disables price exemptions for locally submitted transactions
@ -60,135 +193,3 @@ The ```bor server``` command runs the Bor client.
- ```txpool.globalqueue```: Maximum number of non-executable transaction slots for all accounts - ```txpool.globalqueue```: Maximum number of non-executable transaction slots for all accounts
- ```txpool.lifetime```: Maximum amount of time non-executable transaction are queued - ```txpool.lifetime```: Maximum amount of time non-executable transaction are queued
### Sealer Options
- ```mine```: Enable sealing.
- ```miner.etherbase```: Public address for block mining rewards (default = first account)
- ```miner.extradata```: Block extra data set by the miner (default = client version).
- ```miner.gaslimit```: Target gas ceiling for mined blocks.
- ```miner.gasprice```: Minimum gas price for mining a transaction.
### Cache Options
- ```cache```: Megabytes of memory allocated to internal caching (default = 4096 mainnet full node).
- ```cache.database```: Percentage of cache memory allowance to use for database io.
- ```cache.trie```: Percentage of cache memory allowance to use for trie caching (default = 15% full mode, 30% archive mode).
- ```cache.trie.journal```: Disk journal directory for trie cache to survive node restarts.
- ```cache.trie.rejournal```: Time interval to regenerate the trie cache journal.
- ```cache.gc```: Percentage of cache memory allowance to use for trie pruning (default = 25% full mode, 0% archive mode).
- ```cache.snapshot```: Percentage of cache memory allowance to use for snapshot caching (default = 10% full mode, 20% archive mode).
- ```cache.noprefetch```: Disable heuristic state prefetch during block import (less CPU and disk IO, more time waiting for data).
- ```cache.preimages```: Enable recording the SHA3/keccak preimages of trie keys.
- ```txlookuplimit```: Number of recent blocks to maintain transactions index for (default = about 56 days, 0 = entire chain).
### JsonRPC Options
- ```rpc.gascap```: Sets a cap on gas that can be used in eth_call/estimateGas (0=infinite).
- ```rpc.txfeecap```: Sets a cap on transaction fee (in ether) that can be sent via the RPC APIs (0 = no cap).
- ```ipcdisable```: Disable the IPC-RPC server.
- ```ipcpath```: Filename for IPC socket/pipe within the datadir (explicit paths escape it).
- ```jsonrpc.corsdomain```: Comma separated list of domains from which to accept cross.
- ```jsonrpc.vhosts```: Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.
- ```http```: Enable the HTTP-RPC server.
- ```http.addr```: HTTP-RPC server listening interface.
- ```http.port```: HTTP-RPC server listening port.
- ```http.rpcprefix```: HTTP path path prefix on which JSON-RPC is served. Use '/' to serve on all paths.
- ```http.modules```: API's offered over the HTTP-RPC interface.
- ```ws```: Enable the WS-RPC server.
- ```ws.addr```: WS-RPC server listening interface.
- ```ws.port```: WS-RPC server listening port.
- ```ws.rpcprefix```: HTTP path prefix on which JSON-RPC is served. Use '/' to serve on all paths.
- ```ws.modules```: API's offered over the WS-RPC interface.
- ```graphql```: Enable GraphQL on the HTTP-RPC server. Note that GraphQL can only be started if an HTTP server is started as well.
### P2P Options
- ```bind```: Network binding address
- ```port```: Network listening port
- ```bootnodes```: Comma separated enode URLs for P2P discovery bootstrap
- ```maxpeers```: "Maximum number of network peers (network disabled if set to 0)
- ```maxpendpeers```: Maximum number of pending connection attempts (defaults used if set to 0)
- ```nat```: "NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>)
- ```nodiscover```: "Disables the peer discovery mechanism (manual peer addition)
- ```v5disc```: "Enables the experimental RLPx V5 (Topic Discovery) mechanism
### Telemetry Options
- ```metrics```: Enable metrics collection and reporting.
- ```metrics.expensive```: Enable expensive metrics collection and reporting.
- ```metrics.influxdb```: Enable metrics export/push to an external InfluxDB database (v1).
- ```metrics.influxdb.endpoint```: InfluxDB API endpoint to report metrics to.
- ```metrics.influxdb.database```: InfluxDB database name to push reported metrics to.
- ```metrics.influxdb.username```: Username to authorize access to the database.
- ```metrics.influxdb.password```: Password to authorize access to the database.
- ```metrics.influxdb.tags```: Comma-separated InfluxDB tags (key/values) attached to all measurements.
- ```metrics.influxdbv2```: Enable metrics export/push to an external InfluxDB v2 database.
- ```metrics.influxdb.token```: Token to authorize access to the database (v2 only).
- ```metrics.influxdb.bucket```: InfluxDB bucket name to push reported metrics to (v2 only).
- ```metrics.influxdb.organization```: InfluxDB organization name (v2 only).
### Account Management Options
- ```unlock```: "Comma separated list of accounts to unlock.
- ```password```: Password file to use for non-interactive password input.
- ```allow-insecure-unlock```: Allow insecure account unlocking when account-related RPCs are exposed by http.
- ```lightkdf```: Reduce key-derivation RAM & CPU usage at some expense of KDF strength.
## Usage
Use multiple files to configure the client:
```
$ bor server --config ./legacy-config.toml --config ./config2.hcl
```

View file

@ -1,4 +1,3 @@
# Status # Status
The ```status``` command outputs the status of the client. The ```status``` command outputs the status of the client.

View file

@ -1,4 +1,3 @@
# Version # Version
The ```bor version``` command outputs the version of the binary. The ```bor version``` command outputs the version of the binary.
@ -8,4 +7,4 @@ The ```bor version``` command outputs the version of the binary.
``` ```
$ bor version $ bor version
0.2.9-stable 0.2.9-stable
``` ```

View file

@ -1,11 +1,27 @@
package cli package cli
import "github.com/mitchellh/cli" import (
"strings"
"github.com/mitchellh/cli"
)
type Account struct { type Account struct {
UI cli.Ui UI cli.Ui
} }
// MarkDown implements cli.MarkDown interface
func (a *Account) MarkDown() string {
items := []string{
"# Account",
"The ```account``` command groups actions to interact with accounts:",
"- [```account new```](./account_new.md): Create a new account in the Bor client.",
"- [```account list```](./account_list.md): List the wallets in the Bor client.",
"- [```account import```](./account_import.md): Import an account to the Bor client.",
}
return strings.Join(items, "\n\n")
}
// Help implements the cli.Command interface // Help implements the cli.Command interface
func (a *Account) Help() string { func (a *Account) Help() string {
return `Usage: bor account <subcommand> return `Usage: bor account <subcommand>

View file

@ -2,6 +2,7 @@ package cli
import ( import (
"fmt" "fmt"
"strings"
"github.com/ethereum/go-ethereum/cmd/utils" "github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
@ -12,6 +13,16 @@ type AccountImportCommand struct {
*Meta *Meta
} }
// MarkDown implements cli.MarkDown interface
func (a *AccountImportCommand) MarkDown() string {
items := []string{
"# Account import",
"The ```account import``` command imports an account in Json format to the Bor data directory.",
a.Flags().MarkDown(),
}
return strings.Join(items, "\n\n")
}
// Help implements the cli.Command interface // Help implements the cli.Command interface
func (a *AccountImportCommand) Help() string { func (a *AccountImportCommand) Help() string {
return `Usage: bor account import return `Usage: bor account import

View file

@ -2,6 +2,7 @@ package cli
import ( import (
"fmt" "fmt"
"strings"
"github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/internal/cli/flagset" "github.com/ethereum/go-ethereum/internal/cli/flagset"
@ -11,6 +12,16 @@ type AccountListCommand struct {
*Meta *Meta
} }
// MarkDown implements cli.MarkDown interface
func (a *AccountListCommand) MarkDown() string {
items := []string{
"# Account list",
"The `account list` command lists all the accounts in the Bor data directory.",
a.Flags().MarkDown(),
}
return strings.Join(items, "\n\n")
}
// Help implements the cli.Command interface // Help implements the cli.Command interface
func (a *AccountListCommand) Help() string { func (a *AccountListCommand) Help() string {
return `Usage: bor account list return `Usage: bor account list

View file

@ -2,6 +2,7 @@ package cli
import ( import (
"fmt" "fmt"
"strings"
"github.com/ethereum/go-ethereum/internal/cli/flagset" "github.com/ethereum/go-ethereum/internal/cli/flagset"
) )
@ -10,6 +11,16 @@ type AccountNewCommand struct {
*Meta *Meta
} }
// MarkDown implements cli.MarkDown interface
func (a *AccountNewCommand) MarkDown() string {
items := []string{
"# Account new",
"The `account new` command creates a new local account file on the Bor data directory. Bor should not be running to execute this command.",
a.Flags().MarkDown(),
}
return strings.Join(items, "\n\n")
}
// Help implements the cli.Command interface // Help implements the cli.Command interface
func (a *AccountNewCommand) Help() string { func (a *AccountNewCommand) Help() string {
return `Usage: bor account new return `Usage: bor account new

View file

@ -26,6 +26,16 @@ type AttachCommand struct {
JSpathFlag string JSpathFlag string
} }
// MarkDown implements cli.MarkDown interface
func (c *AttachCommand) MarkDown() string {
items := []string{
"# Attach",
"Connect to remote Bor IPC console.",
c.Flags().MarkDown(),
}
return strings.Join(items, "\n\n")
}
// Help implements the cli.Command interface // Help implements the cli.Command interface
func (c *AttachCommand) Help() string { func (c *AttachCommand) Help() string {
return `Usage: bor attach <IPC FILE> return `Usage: bor attach <IPC FILE>

View file

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"math" "math"
"os/exec" "os/exec"
"strings"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
@ -18,6 +19,15 @@ type FingerprintCommand struct {
UI cli.Ui UI cli.Ui
} }
// MarkDown implements cli.MarkDown interface
func (c *FingerprintCommand) MarkDown() string {
items := []string{
"# Fingerprint",
"Display the system fingerprint",
}
return strings.Join(items, "\n\n")
}
// Help implements the cli.Command interface // Help implements the cli.Command interface
func (c *FingerprintCommand) Help() string { func (c *FingerprintCommand) Help() string {
return `Usage: bor fingerprint return `Usage: bor fingerprint

View file

@ -1,6 +1,8 @@
package cli package cli
import ( import (
"strings"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@ -9,6 +11,17 @@ type ChainCommand struct {
UI cli.Ui UI cli.Ui
} }
// MarkDown implements cli.MarkDown interface
func (c *ChainCommand) MarkDown() string {
items := []string{
"# Chain",
"The ```chain``` command groups actions to interact with the blockchain in the client:",
"- [```chain sethead```](./chain_sethead.md): Set the current chain to a certain block.",
"- [```chain watch```](./chain_watch.md): Watch the chainHead, reorg and fork events in real-time.",
}
return strings.Join(items, "\n\n")
}
// Help implements the cli.Command interface // Help implements the cli.Command interface
func (c *ChainCommand) Help() string { func (c *ChainCommand) Help() string {
return `Usage: bor chain <subcommand> return `Usage: bor chain <subcommand>

View file

@ -4,6 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
"strconv" "strconv"
"strings"
"github.com/ethereum/go-ethereum/internal/cli/flagset" "github.com/ethereum/go-ethereum/internal/cli/flagset"
"github.com/ethereum/go-ethereum/internal/cli/server/proto" "github.com/ethereum/go-ethereum/internal/cli/server/proto"
@ -16,6 +17,18 @@ type ChainSetHeadCommand struct {
yes bool yes bool
} }
// MarkDown implements cli.MarkDown interface
func (a *ChainSetHeadCommand) MarkDown() string {
items := []string{
"# Chain sethead",
"The ```chain sethead <number>``` command sets the current chain to a certain block.",
"## Arguments",
"- ```number```: The block number to roll back.",
a.Flags().MarkDown(),
}
return strings.Join(items, "\n\n")
}
// Help implements the cli.Command interface // Help implements the cli.Command interface
func (c *ChainSetHeadCommand) Help() string { func (c *ChainSetHeadCommand) Help() string {
return `Usage: bor chain sethead <number> [--yes] return `Usage: bor chain sethead <number> [--yes]

View file

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"os" "os"
"os/signal" "os/signal"
"strings"
"syscall" "syscall"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
@ -17,6 +18,15 @@ type ChainWatchCommand struct {
*Meta2 *Meta2
} }
// MarkDown implements cli.MarkDown interface
func (c *ChainWatchCommand) MarkDown() string {
items := []string{
"# Chain watch",
"The ```chain watch``` command is used to view the chainHead, reorg and fork events in real-time.",
}
return strings.Join(items, "\n\n")
}
// Help implements the cli.Command interface // Help implements the cli.Command interface
func (c *ChainWatchCommand) Help() string { func (c *ChainWatchCommand) Help() string {
return `Usage: bor chain watch return `Usage: bor chain watch

View file

@ -14,13 +14,29 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
) )
type MarkDownCommand interface {
MarkDown
cli.Command
}
type MarkDownCommandFactory func() (MarkDownCommand, error)
func Run(args []string) int { func Run(args []string) int {
commands := commands() commands := Commands()
mappedCommands := make(map[string]cli.CommandFactory)
for k, v := range commands {
mappedCommands[k] = func() (cli.Command, error) {
cmd, err := v()
return cmd.(cli.Command), err
}
}
cli := &cli.CLI{ cli := &cli.CLI{
Name: "bor", Name: "bor",
Args: args, Args: args,
Commands: commands, Commands: mappedCommands,
} }
exitCode, err := cli.Run() exitCode, err := cli.Run()
@ -31,7 +47,7 @@ func Run(args []string) int {
return exitCode return exitCode
} }
func commands() map[string]cli.CommandFactory { func Commands() map[string]MarkDownCommandFactory {
ui := &cli.BasicUi{ ui := &cli.BasicUi{
Reader: os.Stdin, Reader: os.Stdin,
Writer: os.Stdout, Writer: os.Stdout,
@ -44,93 +60,93 @@ func commands() map[string]cli.CommandFactory {
meta := &Meta{ meta := &Meta{
UI: ui, UI: ui,
} }
return map[string]cli.CommandFactory{ return map[string]MarkDownCommandFactory{
"server": func() (cli.Command, error) { "server": func() (MarkDownCommand, error) {
return &server.Command{ return &server.Command{
UI: ui, UI: ui,
}, nil }, nil
}, },
"version": func() (cli.Command, error) { "version": func() (MarkDownCommand, error) {
return &VersionCommand{ return &VersionCommand{
UI: ui, UI: ui,
}, nil }, nil
}, },
"debug": func() (cli.Command, error) { "debug": func() (MarkDownCommand, error) {
return &DebugCommand{ return &DebugCommand{
Meta2: meta2, Meta2: meta2,
}, nil }, nil
}, },
"chain": func() (cli.Command, error) { "chain": func() (MarkDownCommand, error) {
return &ChainCommand{ return &ChainCommand{
UI: ui, UI: ui,
}, nil }, nil
}, },
"chain watch": func() (cli.Command, error) { "chain watch": func() (MarkDownCommand, error) {
return &ChainWatchCommand{ return &ChainWatchCommand{
Meta2: meta2, Meta2: meta2,
}, nil }, nil
}, },
"chain sethead": func() (cli.Command, error) { "chain sethead": func() (MarkDownCommand, error) {
return &ChainSetHeadCommand{ return &ChainSetHeadCommand{
Meta2: meta2, Meta2: meta2,
}, nil }, nil
}, },
"account": func() (cli.Command, error) { "account": func() (MarkDownCommand, error) {
return &Account{ return &Account{
UI: ui, UI: ui,
}, nil }, nil
}, },
"account new": func() (cli.Command, error) { "account new": func() (MarkDownCommand, error) {
return &AccountNewCommand{ return &AccountNewCommand{
Meta: meta, Meta: meta,
}, nil }, nil
}, },
"account import": func() (cli.Command, error) { "account import": func() (MarkDownCommand, error) {
return &AccountImportCommand{ return &AccountImportCommand{
Meta: meta, Meta: meta,
}, nil }, nil
}, },
"account list": func() (cli.Command, error) { "account list": func() (MarkDownCommand, error) {
return &AccountListCommand{ return &AccountListCommand{
Meta: meta, Meta: meta,
}, nil }, nil
}, },
"peers": func() (cli.Command, error) { "peers": func() (MarkDownCommand, error) {
return &PeersCommand{ return &PeersCommand{
UI: ui, UI: ui,
}, nil }, nil
}, },
"peers add": func() (cli.Command, error) { "peers add": func() (MarkDownCommand, error) {
return &PeersAddCommand{ return &PeersAddCommand{
Meta2: meta2, Meta2: meta2,
}, nil }, nil
}, },
"peers remove": func() (cli.Command, error) { "peers remove": func() (MarkDownCommand, error) {
return &PeersRemoveCommand{ return &PeersRemoveCommand{
Meta2: meta2, Meta2: meta2,
}, nil }, nil
}, },
"peers list": func() (cli.Command, error) { "peers list": func() (MarkDownCommand, error) {
return &PeersListCommand{ return &PeersListCommand{
Meta2: meta2, Meta2: meta2,
}, nil }, nil
}, },
"peers status": func() (cli.Command, error) { "peers status": func() (MarkDownCommand, error) {
return &PeersStatusCommand{ return &PeersStatusCommand{
Meta2: meta2, Meta2: meta2,
}, nil }, nil
}, },
"status": func() (cli.Command, error) { "status": func() (MarkDownCommand, error) {
return &StatusCommand{ return &StatusCommand{
Meta2: meta2, Meta2: meta2,
}, nil }, nil
}, },
"fingerprint": func() (cli.Command, error) { "fingerprint": func() (MarkDownCommand, error) {
return &FingerprintCommand{ return &FingerprintCommand{
UI: ui, UI: ui,
}, nil }, nil
}, },
"attach": func() (cli.Command, error) { "attach": func() (MarkDownCommand, error) {
return &AttachCommand{ return &AttachCommand{
UI: ui, UI: ui,
Meta: meta, Meta: meta,

View file

@ -31,6 +31,33 @@ type DebugCommand struct {
output string output string
} }
// MarkDown implements cli.MarkDown interface
func (d *DebugCommand) MarkDown() string {
examples := []string{
"## Examples",
"By default it creates a tar.gz file with the output:",
CodeBlock([]string{
"$ bor debug",
"Starting debugger...\n",
"Created debug archive: bor-debug-2021-10-26-073819Z.tar.gz",
}),
"Send the output to a specific directory:",
CodeBlock([]string{
"$ bor debug --output data",
"Starting debugger...\n",
"Created debug directory: data/bor-debug-2021-10-26-075437Z",
}),
}
items := []string{
"# Debug",
"The ```bor debug``` command takes a debug dump of the running client.",
d.Flags().MarkDown(),
}
items = append(items, examples...)
return strings.Join(items, "\n\n")
}
// Help implements the cli.Command interface // Help implements the cli.Command interface
func (d *DebugCommand) Help() string { func (d *DebugCommand) Help() string {
return `Usage: bor debug return `Usage: bor debug

View file

@ -4,6 +4,7 @@ import (
"flag" "flag"
"fmt" "fmt"
"math/big" "math/big"
"sort"
"strings" "strings"
"time" "time"
) )
@ -24,6 +25,7 @@ func NewFlagSet(name string) *Flagset {
type FlagVar struct { type FlagVar struct {
Name string Name string
Usage string Usage string
Group string
} }
func (f *Flagset) addFlag(fl *FlagVar) { func (f *Flagset) addFlag(fl *FlagVar) {
@ -39,6 +41,40 @@ func (f *Flagset) Help() string {
return str + strings.Join(items, "\n\n") return str + strings.Join(items, "\n\n")
} }
// MarkDown implements cli.MarkDown interface
func (f *Flagset) MarkDown() string {
if len(f.flags) == 0 {
return ""
}
groups := make(map[string][]*FlagVar)
for _, item := range f.flags {
groups[item.Group] = append(groups[item.Group], item)
}
keys := make([]string, len(groups))
i := 0
for k := range groups {
keys[i] = k
i++
}
sort.Strings(keys)
items := []string{}
for _, k := range keys {
if k == "" {
items = append(items, fmt.Sprintf("## Options"))
} else {
items = append(items, fmt.Sprintf("### %s Options", k))
}
for _, item := range groups[k] {
items = append(items, fmt.Sprintf("- ```%s```: %s", item.Name, item.Usage))
}
}
return strings.Join(items, "\n\n")
}
func (f *Flagset) Parse(args []string) error { func (f *Flagset) Parse(args []string) error {
return f.set.Parse(args) return f.set.Parse(args)
} }
@ -52,12 +88,14 @@ type BoolFlag struct {
Usage string Usage string
Default bool Default bool
Value *bool Value *bool
Group string
} }
func (f *Flagset) BoolFlag(b *BoolFlag) { func (f *Flagset) BoolFlag(b *BoolFlag) {
f.addFlag(&FlagVar{ f.addFlag(&FlagVar{
Name: b.Name, Name: b.Name,
Usage: b.Usage, Usage: b.Usage,
Group: b.Group,
}) })
f.set.BoolVar(b.Value, b.Name, b.Default, b.Usage) f.set.BoolVar(b.Value, b.Name, b.Default, b.Usage)
} }
@ -67,12 +105,14 @@ type StringFlag struct {
Usage string Usage string
Default string Default string
Value *string Value *string
Group string
} }
func (f *Flagset) StringFlag(b *StringFlag) { func (f *Flagset) StringFlag(b *StringFlag) {
f.addFlag(&FlagVar{ f.addFlag(&FlagVar{
Name: b.Name, Name: b.Name,
Usage: b.Usage, Usage: b.Usage,
Group: b.Group,
}) })
f.set.StringVar(b.Value, b.Name, b.Default, b.Usage) f.set.StringVar(b.Value, b.Name, b.Default, b.Usage)
} }
@ -82,12 +122,14 @@ type IntFlag struct {
Usage string Usage string
Value *int Value *int
Default int Default int
Group string
} }
func (f *Flagset) IntFlag(i *IntFlag) { func (f *Flagset) IntFlag(i *IntFlag) {
f.addFlag(&FlagVar{ f.addFlag(&FlagVar{
Name: i.Name, Name: i.Name,
Usage: i.Usage, Usage: i.Usage,
Group: i.Group,
}) })
f.set.IntVar(i.Value, i.Name, i.Default, i.Usage) f.set.IntVar(i.Value, i.Name, i.Default, i.Usage)
} }
@ -97,12 +139,14 @@ type Uint64Flag struct {
Usage string Usage string
Value *uint64 Value *uint64
Default uint64 Default uint64
Group string
} }
func (f *Flagset) Uint64Flag(i *Uint64Flag) { func (f *Flagset) Uint64Flag(i *Uint64Flag) {
f.addFlag(&FlagVar{ f.addFlag(&FlagVar{
Name: i.Name, Name: i.Name,
Usage: i.Usage, Usage: i.Usage,
Group: i.Group,
}) })
f.set.Uint64Var(i.Value, i.Name, i.Default, i.Usage) f.set.Uint64Var(i.Value, i.Name, i.Default, i.Usage)
} }
@ -111,6 +155,7 @@ type BigIntFlag struct {
Name string Name string
Usage string Usage string
Value *big.Int Value *big.Int
Group string
} }
func (b *BigIntFlag) String() string { func (b *BigIntFlag) String() string {
@ -140,6 +185,7 @@ func (f *Flagset) BigIntFlag(b *BigIntFlag) {
f.addFlag(&FlagVar{ f.addFlag(&FlagVar{
Name: b.Name, Name: b.Name,
Usage: b.Usage, Usage: b.Usage,
Group: b.Group,
}) })
f.set.Var(b, b.Name, b.Usage) f.set.Var(b, b.Name, b.Usage)
} }
@ -148,6 +194,7 @@ type SliceStringFlag struct {
Name string Name string
Usage string Usage string
Value *[]string Value *[]string
Group string
} }
func (i *SliceStringFlag) String() string { func (i *SliceStringFlag) String() string {
@ -166,6 +213,7 @@ func (f *Flagset) SliceStringFlag(s *SliceStringFlag) {
f.addFlag(&FlagVar{ f.addFlag(&FlagVar{
Name: s.Name, Name: s.Name,
Usage: s.Usage, Usage: s.Usage,
Group: s.Group,
}) })
f.set.Var(s, s.Name, s.Usage) f.set.Var(s, s.Name, s.Usage)
} }
@ -175,12 +223,14 @@ type DurationFlag struct {
Usage string Usage string
Value *time.Duration Value *time.Duration
Default time.Duration Default time.Duration
Group string
} }
func (f *Flagset) DurationFlag(d *DurationFlag) { func (f *Flagset) DurationFlag(d *DurationFlag) {
f.addFlag(&FlagVar{ f.addFlag(&FlagVar{
Name: d.Name, Name: d.Name,
Usage: d.Usage, Usage: d.Usage,
Group: d.Group,
}) })
f.set.DurationVar(d.Value, d.Name, d.Default, "") f.set.DurationVar(d.Value, d.Name, d.Default, "")
} }
@ -189,6 +239,7 @@ type MapStringFlag struct {
Name string Name string
Usage string Usage string
Value *map[string]string Value *map[string]string
Group string
} }
func (m *MapStringFlag) String() string { func (m *MapStringFlag) String() string {
@ -222,6 +273,7 @@ func (f *Flagset) MapStringFlag(m *MapStringFlag) {
f.addFlag(&FlagVar{ f.addFlag(&FlagVar{
Name: m.Name, Name: m.Name,
Usage: m.Usage, Usage: m.Usage,
Group: m.Group,
}) })
f.set.Var(m, m.Name, m.Usage) f.set.Var(m, m.Name, m.Usage)
} }
@ -231,12 +283,14 @@ type Float64Flag struct {
Usage string Usage string
Value *float64 Value *float64
Default float64 Default float64
Group string
} }
func (f *Flagset) Float64Flag(i *Float64Flag) { func (f *Flagset) Float64Flag(i *Float64Flag) {
f.addFlag(&FlagVar{ f.addFlag(&FlagVar{
Name: i.Name, Name: i.Name,
Usage: i.Usage, Usage: i.Usage,
Group: i.Group,
}) })
f.set.Float64Var(i.Value, i.Name, i.Default, "") f.set.Float64Var(i.Value, i.Name, i.Default, "")
} }

14
internal/cli/markdown.go Normal file
View file

@ -0,0 +1,14 @@
package cli
import (
"strings"
)
type MarkDown interface {
MarkDown() string
}
// Create a Markdown code block from a slice of string, where each string is a line of code
func CodeBlock(lines []string) string {
return "```\n" + strings.Join(lines, "\n") + "\n```"
}

View file

@ -0,0 +1,19 @@
package cli
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestCodeBlock(t *testing.T) {
assert := assert.New(t)
lines := []string{
"abc",
"bcd",
}
expected := "```\n" + "abc\n" + "bcd\n" + "```"
assert.Equal(expected, CodeBlock(lines))
}

View file

@ -1,6 +1,8 @@
package cli package cli
import ( import (
"strings"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@ -9,6 +11,19 @@ type PeersCommand struct {
UI cli.Ui UI cli.Ui
} }
// MarkDown implements cli.MarkDown interface
func (a *PeersCommand) MarkDown() string {
items := []string{
"# Peers",
"The ```peers``` command groups actions to interact with peers:",
"- [```peers add```](./peers_add.md): Joins the local client to another remote peer.",
"- [```peers list```](./peers_list.md): Lists the connected peers to the Bor client.",
"- [```peers remove```](./peers_remove.md): Disconnects the local client from a connected peer if exists.",
"- [```peers status```](./peers_status.md): Display the status of a peer by its id.",
}
return strings.Join(items, "\n\n")
}
// Help implements the cli.Command interface // Help implements the cli.Command interface
func (c *PeersCommand) Help() string { func (c *PeersCommand) Help() string {
return `Usage: bor peers <subcommand> return `Usage: bor peers <subcommand>

View file

@ -2,6 +2,7 @@ package cli
import ( import (
"context" "context"
"strings"
"github.com/ethereum/go-ethereum/internal/cli/flagset" "github.com/ethereum/go-ethereum/internal/cli/flagset"
"github.com/ethereum/go-ethereum/internal/cli/server/proto" "github.com/ethereum/go-ethereum/internal/cli/server/proto"
@ -14,6 +15,16 @@ type PeersAddCommand struct {
trusted bool trusted bool
} }
// MarkDown implements cli.MarkDown interface
func (p *PeersAddCommand) MarkDown() string {
items := []string{
"# Peers add",
"The ```peers add <enode>``` command joins the local client to another remote peer.",
p.Flags().MarkDown(),
}
return strings.Join(items, "\n\n")
}
// Help implements the cli.Command interface // Help implements the cli.Command interface
func (p *PeersAddCommand) Help() string { func (p *PeersAddCommand) Help() string {
return `Usage: bor peers add <enode> return `Usage: bor peers add <enode>

View file

@ -14,6 +14,16 @@ type PeersListCommand struct {
*Meta2 *Meta2
} }
// MarkDown implements cli.MarkDown interface
func (p *PeersListCommand) MarkDown() string {
items := []string{
"# Peers add",
"The ```peers list``` command lists the connected peers.",
p.Flags().MarkDown(),
}
return strings.Join(items, "\n\n")
}
// Help implements the cli.Command interface // Help implements the cli.Command interface
func (p *PeersListCommand) Help() string { func (p *PeersListCommand) Help() string {
return `Usage: bor peers list return `Usage: bor peers list

View file

@ -2,6 +2,7 @@ package cli
import ( import (
"context" "context"
"strings"
"github.com/ethereum/go-ethereum/internal/cli/flagset" "github.com/ethereum/go-ethereum/internal/cli/flagset"
"github.com/ethereum/go-ethereum/internal/cli/server/proto" "github.com/ethereum/go-ethereum/internal/cli/server/proto"
@ -14,6 +15,16 @@ type PeersRemoveCommand struct {
trusted bool trusted bool
} }
// MarkDown implements cli.MarkDown interface
func (p *PeersRemoveCommand) MarkDown() string {
items := []string{
"# Peers remove",
"The ```peers remove <enode>``` command disconnects the local client from a connected peer if exists.",
p.Flags().MarkDown(),
}
return strings.Join(items, "\n\n")
}
// Help implements the cli.Command interface // Help implements the cli.Command interface
func (p *PeersRemoveCommand) Help() string { func (p *PeersRemoveCommand) Help() string {
return `Usage: bor peers remove <enode> return `Usage: bor peers remove <enode>

View file

@ -14,6 +14,16 @@ type PeersStatusCommand struct {
*Meta2 *Meta2
} }
// MarkDown implements cli.MarkDown interface
func (p *PeersStatusCommand) MarkDown() string {
items := []string{
"# Peers status",
"The ```peers status <peer id>``` command displays the status of a peer by its id.",
p.Flags().MarkDown(),
}
return strings.Join(items, "\n\n")
}
// Help implements the cli.Command interface // Help implements the cli.Command interface
func (p *PeersStatusCommand) Help() string { func (p *PeersStatusCommand) Help() string {
return `Usage: bor peers status <peer id> return `Usage: bor peers status <peer id>

View file

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"os" "os"
"os/signal" "os/signal"
"strings"
"syscall" "syscall"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
@ -25,6 +26,16 @@ type Command struct {
srv *Server srv *Server
} }
// MarkDown implements cli.MarkDown interface
func (c *Command) MarkDown() string {
items := []string{
"# Server",
"The ```bor server``` command runs the Bor client.",
c.Flags().MarkDown(),
}
return strings.Join(items, "\n\n")
}
// Help implements the cli.Command interface // Help implements the cli.Command interface
func (c *Command) Help() string { func (c *Command) Help() string {
return `Usage: bor [options] return `Usage: bor [options]

View file

@ -36,7 +36,7 @@ func (c *Command) Flags() *flagset.Flagset {
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "syncmode", Name: "syncmode",
Usage: `Blockchain sync mode ("fast", "full", "snap" or "light")`, Usage: `Blockchain sync mode ("fast", "full", or "snap")`,
Value: &c.cliConfig.SyncMode, Value: &c.cliConfig.SyncMode,
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
@ -72,56 +72,67 @@ func (c *Command) Flags() *flagset.Flagset {
Name: "txpool.locals", Name: "txpool.locals",
Usage: "Comma separated accounts to treat as locals (no flush, priority inclusion)", Usage: "Comma separated accounts to treat as locals (no flush, priority inclusion)",
Value: &c.cliConfig.TxPool.Locals, Value: &c.cliConfig.TxPool.Locals,
Group: "Transaction Pool",
}) })
f.BoolFlag(&flagset.BoolFlag{ f.BoolFlag(&flagset.BoolFlag{
Name: "txpool.nolocals", Name: "txpool.nolocals",
Usage: "Disables price exemptions for locally submitted transactions", Usage: "Disables price exemptions for locally submitted transactions",
Value: &c.cliConfig.TxPool.NoLocals, Value: &c.cliConfig.TxPool.NoLocals,
Group: "Transaction Pool",
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "txpool.journal", Name: "txpool.journal",
Usage: "Disk journal for local transaction to survive node restarts", Usage: "Disk journal for local transaction to survive node restarts",
Value: &c.cliConfig.TxPool.Journal, Value: &c.cliConfig.TxPool.Journal,
Group: "Transaction Pool",
}) })
f.DurationFlag(&flagset.DurationFlag{ f.DurationFlag(&flagset.DurationFlag{
Name: "txpool.rejournal", Name: "txpool.rejournal",
Usage: "Time interval to regenerate the local transaction journal", Usage: "Time interval to regenerate the local transaction journal",
Value: &c.cliConfig.TxPool.Rejournal, Value: &c.cliConfig.TxPool.Rejournal,
Group: "Transaction Pool",
}) })
f.Uint64Flag(&flagset.Uint64Flag{ f.Uint64Flag(&flagset.Uint64Flag{
Name: "txpool.pricelimit", Name: "txpool.pricelimit",
Usage: "Minimum gas price limit to enforce for acceptance into the pool", Usage: "Minimum gas price limit to enforce for acceptance into the pool",
Value: &c.cliConfig.TxPool.PriceLimit, Value: &c.cliConfig.TxPool.PriceLimit,
Group: "Transaction Pool",
}) })
f.Uint64Flag(&flagset.Uint64Flag{ f.Uint64Flag(&flagset.Uint64Flag{
Name: "txpool.pricebump", Name: "txpool.pricebump",
Usage: "Price bump percentage to replace an already existing transaction", Usage: "Price bump percentage to replace an already existing transaction",
Value: &c.cliConfig.TxPool.PriceBump, Value: &c.cliConfig.TxPool.PriceBump,
Group: "Transaction Pool",
}) })
f.Uint64Flag(&flagset.Uint64Flag{ f.Uint64Flag(&flagset.Uint64Flag{
Name: "txpool.accountslots", Name: "txpool.accountslots",
Usage: "Minimum number of executable transaction slots guaranteed per account", Usage: "Minimum number of executable transaction slots guaranteed per account",
Value: &c.cliConfig.TxPool.AccountSlots, Value: &c.cliConfig.TxPool.AccountSlots,
Group: "Transaction Pool",
}) })
f.Uint64Flag(&flagset.Uint64Flag{ f.Uint64Flag(&flagset.Uint64Flag{
Name: "txpool.globalslots", Name: "txpool.globalslots",
Usage: "Maximum number of executable transaction slots for all accounts", Usage: "Maximum number of executable transaction slots for all accounts",
Value: &c.cliConfig.TxPool.GlobalSlots, Value: &c.cliConfig.TxPool.GlobalSlots,
Group: "Transaction Pool",
}) })
f.Uint64Flag(&flagset.Uint64Flag{ f.Uint64Flag(&flagset.Uint64Flag{
Name: "txpool.accountqueue", Name: "txpool.accountqueue",
Usage: "Maximum number of non-executable transaction slots permitted per account", Usage: "Maximum number of non-executable transaction slots permitted per account",
Value: &c.cliConfig.TxPool.AccountQueue, Value: &c.cliConfig.TxPool.AccountQueue,
Group: "Transaction Pool",
}) })
f.Uint64Flag(&flagset.Uint64Flag{ f.Uint64Flag(&flagset.Uint64Flag{
Name: "txpool.globalqueue", Name: "txpool.globalqueue",
Usage: "Maximum number of non-executable transaction slots for all accounts", Usage: "Maximum number of non-executable transaction slots for all accounts",
Value: &c.cliConfig.TxPool.GlobalQueue, Value: &c.cliConfig.TxPool.GlobalQueue,
Group: "Transaction Pool",
}) })
f.DurationFlag(&flagset.DurationFlag{ f.DurationFlag(&flagset.DurationFlag{
Name: "txpool.lifetime", Name: "txpool.lifetime",
Usage: "Maximum amount of time non-executable transaction are queued", Usage: "Maximum amount of time non-executable transaction are queued",
Value: &c.cliConfig.TxPool.LifeTime, Value: &c.cliConfig.TxPool.LifeTime,
Group: "Transaction Pool",
}) })
// sealer options // sealer options
@ -129,26 +140,31 @@ func (c *Command) Flags() *flagset.Flagset {
Name: "mine", Name: "mine",
Usage: "Enable mining", Usage: "Enable mining",
Value: &c.cliConfig.Sealer.Enabled, Value: &c.cliConfig.Sealer.Enabled,
Group: "Sealer",
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "miner.etherbase", Name: "miner.etherbase",
Usage: "Public address for block mining rewards (default = first account)", Usage: "Public address for block mining rewards (default = first account)",
Value: &c.cliConfig.Sealer.Etherbase, Value: &c.cliConfig.Sealer.Etherbase,
Group: "Sealer",
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "miner.extradata", Name: "miner.extradata",
Usage: "Block extra data set by the miner (default = client version)", Usage: "Block extra data set by the miner (default = client version)",
Value: &c.cliConfig.Sealer.ExtraData, Value: &c.cliConfig.Sealer.ExtraData,
Group: "Sealer",
}) })
f.Uint64Flag(&flagset.Uint64Flag{ f.Uint64Flag(&flagset.Uint64Flag{
Name: "miner.gaslimit", Name: "miner.gaslimit",
Usage: "Target gas ceiling for mined blocks", Usage: "Target gas ceiling for mined blocks",
Value: &c.cliConfig.Sealer.GasCeil, Value: &c.cliConfig.Sealer.GasCeil,
Group: "Sealer",
}) })
f.BigIntFlag(&flagset.BigIntFlag{ f.BigIntFlag(&flagset.BigIntFlag{
Name: "miner.gasprice", Name: "miner.gasprice",
Usage: "Minimum gas price for mining a transaction", Usage: "Minimum gas price for mining a transaction",
Value: c.cliConfig.Sealer.GasPrice, Value: c.cliConfig.Sealer.GasPrice,
Group: "Sealer",
}) })
// ethstats // ethstats
@ -185,51 +201,61 @@ func (c *Command) Flags() *flagset.Flagset {
Name: "cache", Name: "cache",
Usage: "Megabytes of memory allocated to internal caching (default = 4096 mainnet full node)", Usage: "Megabytes of memory allocated to internal caching (default = 4096 mainnet full node)",
Value: &c.cliConfig.Cache.Cache, Value: &c.cliConfig.Cache.Cache,
Group: "Cache",
}) })
f.Uint64Flag(&flagset.Uint64Flag{ f.Uint64Flag(&flagset.Uint64Flag{
Name: "cache.database", Name: "cache.database",
Usage: "Percentage of cache memory allowance to use for database io", Usage: "Percentage of cache memory allowance to use for database io",
Value: &c.cliConfig.Cache.PercDatabase, Value: &c.cliConfig.Cache.PercDatabase,
Group: "Cache",
}) })
f.Uint64Flag(&flagset.Uint64Flag{ f.Uint64Flag(&flagset.Uint64Flag{
Name: "cache.trie", Name: "cache.trie",
Usage: "Percentage of cache memory allowance to use for trie caching (default = 15% full mode, 30% archive mode)", Usage: "Percentage of cache memory allowance to use for trie caching (default = 15% full mode, 30% archive mode)",
Value: &c.cliConfig.Cache.PercTrie, Value: &c.cliConfig.Cache.PercTrie,
Group: "Cache",
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "cache.trie.journal", Name: "cache.trie.journal",
Usage: "Disk journal directory for trie cache to survive node restarts", Usage: "Disk journal directory for trie cache to survive node restarts",
Value: &c.cliConfig.Cache.Journal, Value: &c.cliConfig.Cache.Journal,
Group: "Cache",
}) })
f.DurationFlag(&flagset.DurationFlag{ f.DurationFlag(&flagset.DurationFlag{
Name: "cache.trie.rejournal", Name: "cache.trie.rejournal",
Usage: "Time interval to regenerate the trie cache journal", Usage: "Time interval to regenerate the trie cache journal",
Value: &c.cliConfig.Cache.Rejournal, Value: &c.cliConfig.Cache.Rejournal,
Group: "Cache",
}) })
f.Uint64Flag(&flagset.Uint64Flag{ f.Uint64Flag(&flagset.Uint64Flag{
Name: "cache.gc", Name: "cache.gc",
Usage: "Percentage of cache memory allowance to use for trie pruning (default = 25% full mode, 0% archive mode)", Usage: "Percentage of cache memory allowance to use for trie pruning (default = 25% full mode, 0% archive mode)",
Value: &c.cliConfig.Cache.PercGc, Value: &c.cliConfig.Cache.PercGc,
Group: "Cache",
}) })
f.Uint64Flag(&flagset.Uint64Flag{ f.Uint64Flag(&flagset.Uint64Flag{
Name: "cache.snapshot", Name: "cache.snapshot",
Usage: "Percentage of cache memory allowance to use for snapshot caching (default = 10% full mode, 20% archive mode)", Usage: "Percentage of cache memory allowance to use for snapshot caching (default = 10% full mode, 20% archive mode)",
Value: &c.cliConfig.Cache.PercSnapshot, Value: &c.cliConfig.Cache.PercSnapshot,
Group: "Cache",
}) })
f.BoolFlag(&flagset.BoolFlag{ f.BoolFlag(&flagset.BoolFlag{
Name: "cache.noprefetch", Name: "cache.noprefetch",
Usage: "Disable heuristic state prefetch during block import (less CPU and disk IO, more time waiting for data)", Usage: "Disable heuristic state prefetch during block import (less CPU and disk IO, more time waiting for data)",
Value: &c.cliConfig.Cache.NoPrefetch, Value: &c.cliConfig.Cache.NoPrefetch,
Group: "Cache",
}) })
f.BoolFlag(&flagset.BoolFlag{ f.BoolFlag(&flagset.BoolFlag{
Name: "cache.preimages", Name: "cache.preimages",
Usage: "Enable recording the SHA3/keccak preimages of trie keys", Usage: "Enable recording the SHA3/keccak preimages of trie keys",
Value: &c.cliConfig.Cache.Preimages, Value: &c.cliConfig.Cache.Preimages,
Group: "Cache",
}) })
f.Uint64Flag(&flagset.Uint64Flag{ f.Uint64Flag(&flagset.Uint64Flag{
Name: "txlookuplimit", Name: "txlookuplimit",
Usage: "Number of recent blocks to maintain transactions index for (default = about 56 days, 0 = entire chain)", Usage: "Number of recent blocks to maintain transactions index for (default = about 56 days, 0 = entire chain)",
Value: &c.cliConfig.Cache.TxLookupLimit, Value: &c.cliConfig.Cache.TxLookupLimit,
Group: "Cache",
}) })
// rpc options // rpc options
@ -237,31 +263,37 @@ func (c *Command) Flags() *flagset.Flagset {
Name: "rpc.gascap", Name: "rpc.gascap",
Usage: "Sets a cap on gas that can be used in eth_call/estimateGas (0=infinite)", Usage: "Sets a cap on gas that can be used in eth_call/estimateGas (0=infinite)",
Value: &c.cliConfig.JsonRPC.GasCap, Value: &c.cliConfig.JsonRPC.GasCap,
Group: "JsonRPC",
}) })
f.Float64Flag(&flagset.Float64Flag{ f.Float64Flag(&flagset.Float64Flag{
Name: "rpc.txfeecap", Name: "rpc.txfeecap",
Usage: "Sets a cap on transaction fee (in ether) that can be sent via the RPC APIs (0 = no cap)", Usage: "Sets a cap on transaction fee (in ether) that can be sent via the RPC APIs (0 = no cap)",
Value: &c.cliConfig.JsonRPC.TxFeeCap, Value: &c.cliConfig.JsonRPC.TxFeeCap,
Group: "JsonRPC",
}) })
f.BoolFlag(&flagset.BoolFlag{ f.BoolFlag(&flagset.BoolFlag{
Name: "ipcdisable", Name: "ipcdisable",
Usage: "Disable the IPC-RPC server", Usage: "Disable the IPC-RPC server",
Value: &c.cliConfig.JsonRPC.IPCDisable, Value: &c.cliConfig.JsonRPC.IPCDisable,
Group: "JsonRPC",
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "ipcpath", Name: "ipcpath",
Usage: "Filename for IPC socket/pipe within the datadir (explicit paths escape it)", Usage: "Filename for IPC socket/pipe within the datadir (explicit paths escape it)",
Value: &c.cliConfig.JsonRPC.IPCPath, Value: &c.cliConfig.JsonRPC.IPCPath,
Group: "JsonRPC",
}) })
f.SliceStringFlag(&flagset.SliceStringFlag{ f.SliceStringFlag(&flagset.SliceStringFlag{
Name: "jsonrpc.corsdomain", Name: "jsonrpc.corsdomain",
Usage: "Comma separated list of domains from which to accept cross origin requests (browser enforced)", Usage: "Comma separated list of domains from which to accept cross origin requests (browser enforced)",
Value: &c.cliConfig.JsonRPC.Cors, Value: &c.cliConfig.JsonRPC.Cors,
Group: "JsonRPC",
}) })
f.SliceStringFlag(&flagset.SliceStringFlag{ f.SliceStringFlag(&flagset.SliceStringFlag{
Name: "jsonrpc.vhosts", Name: "jsonrpc.vhosts",
Usage: "Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.", Usage: "Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.",
Value: &c.cliConfig.JsonRPC.VHost, Value: &c.cliConfig.JsonRPC.VHost,
Group: "JsonRPC",
}) })
// http options // http options
@ -269,26 +301,31 @@ func (c *Command) Flags() *flagset.Flagset {
Name: "http", Name: "http",
Usage: "Enable the HTTP-RPC server", Usage: "Enable the HTTP-RPC server",
Value: &c.cliConfig.JsonRPC.Http.Enabled, Value: &c.cliConfig.JsonRPC.Http.Enabled,
Group: "JsonRPC",
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "http.addr", Name: "http.addr",
Usage: "HTTP-RPC server listening interface", Usage: "HTTP-RPC server listening interface",
Value: &c.cliConfig.JsonRPC.Http.Host, Value: &c.cliConfig.JsonRPC.Http.Host,
Group: "JsonRPC",
}) })
f.Uint64Flag(&flagset.Uint64Flag{ f.Uint64Flag(&flagset.Uint64Flag{
Name: "http.port", Name: "http.port",
Usage: "HTTP-RPC server listening port", Usage: "HTTP-RPC server listening port",
Value: &c.cliConfig.JsonRPC.Http.Port, Value: &c.cliConfig.JsonRPC.Http.Port,
Group: "JsonRPC",
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "http.rpcprefix", Name: "http.rpcprefix",
Usage: "HTTP path path prefix on which JSON-RPC is served. Use '/' to serve on all paths.", Usage: "HTTP path path prefix on which JSON-RPC is served. Use '/' to serve on all paths.",
Value: &c.cliConfig.JsonRPC.Http.Prefix, Value: &c.cliConfig.JsonRPC.Http.Prefix,
Group: "JsonRPC",
}) })
f.SliceStringFlag(&flagset.SliceStringFlag{ f.SliceStringFlag(&flagset.SliceStringFlag{
Name: "http.modules", Name: "http.modules",
Usage: "API's offered over the HTTP-RPC interface", Usage: "API's offered over the HTTP-RPC interface",
Value: &c.cliConfig.JsonRPC.Http.Modules, Value: &c.cliConfig.JsonRPC.Http.Modules,
Group: "JsonRPC",
}) })
// ws options // ws options
@ -296,26 +333,31 @@ func (c *Command) Flags() *flagset.Flagset {
Name: "ws", Name: "ws",
Usage: "Enable the WS-RPC server", Usage: "Enable the WS-RPC server",
Value: &c.cliConfig.JsonRPC.Ws.Enabled, Value: &c.cliConfig.JsonRPC.Ws.Enabled,
Group: "JsonRPC",
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "ws.addr", Name: "ws.addr",
Usage: "WS-RPC server listening interface", Usage: "WS-RPC server listening interface",
Value: &c.cliConfig.JsonRPC.Ws.Host, Value: &c.cliConfig.JsonRPC.Ws.Host,
Group: "JsonRPC",
}) })
f.Uint64Flag(&flagset.Uint64Flag{ f.Uint64Flag(&flagset.Uint64Flag{
Name: "ws.port", Name: "ws.port",
Usage: "WS-RPC server listening port", Usage: "WS-RPC server listening port",
Value: &c.cliConfig.JsonRPC.Ws.Port, Value: &c.cliConfig.JsonRPC.Ws.Port,
Group: "JsonRPC",
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "ws.rpcprefix", Name: "ws.rpcprefix",
Usage: "HTTP path prefix on which JSON-RPC is served. Use '/' to serve on all paths.", Usage: "HTTP path prefix on which JSON-RPC is served. Use '/' to serve on all paths.",
Value: &c.cliConfig.JsonRPC.Ws.Prefix, Value: &c.cliConfig.JsonRPC.Ws.Prefix,
Group: "JsonRPC",
}) })
f.SliceStringFlag(&flagset.SliceStringFlag{ f.SliceStringFlag(&flagset.SliceStringFlag{
Name: "ws.modules", Name: "ws.modules",
Usage: "API's offered over the WS-RPC interface", Usage: "API's offered over the WS-RPC interface",
Value: &c.cliConfig.JsonRPC.Ws.Modules, Value: &c.cliConfig.JsonRPC.Ws.Modules,
Group: "JsonRPC",
}) })
// graphql options // graphql options
@ -323,6 +365,7 @@ func (c *Command) Flags() *flagset.Flagset {
Name: "graphql", Name: "graphql",
Usage: "Enable GraphQL on the HTTP-RPC server. Note that GraphQL can only be started if an HTTP server is started as well.", Usage: "Enable GraphQL on the HTTP-RPC server. Note that GraphQL can only be started if an HTTP server is started as well.",
Value: &c.cliConfig.JsonRPC.Graphql.Enabled, Value: &c.cliConfig.JsonRPC.Graphql.Enabled,
Group: "JsonRPC",
}) })
// p2p options // p2p options
@ -330,41 +373,49 @@ func (c *Command) Flags() *flagset.Flagset {
Name: "bind", Name: "bind",
Usage: "Network binding address", Usage: "Network binding address",
Value: &c.cliConfig.P2P.Bind, Value: &c.cliConfig.P2P.Bind,
Group: "P2P",
}) })
f.Uint64Flag(&flagset.Uint64Flag{ f.Uint64Flag(&flagset.Uint64Flag{
Name: "port", Name: "port",
Usage: "Network listening port", Usage: "Network listening port",
Value: &c.cliConfig.P2P.Port, Value: &c.cliConfig.P2P.Port,
Group: "P2P",
}) })
f.SliceStringFlag(&flagset.SliceStringFlag{ f.SliceStringFlag(&flagset.SliceStringFlag{
Name: "bootnodes", Name: "bootnodes",
Usage: "Comma separated enode URLs for P2P discovery bootstrap", Usage: "Comma separated enode URLs for P2P discovery bootstrap",
Value: &c.cliConfig.P2P.Discovery.Bootnodes, Value: &c.cliConfig.P2P.Discovery.Bootnodes,
Group: "P2P",
}) })
f.Uint64Flag(&flagset.Uint64Flag{ f.Uint64Flag(&flagset.Uint64Flag{
Name: "maxpeers", Name: "maxpeers",
Usage: "Maximum number of network peers (network disabled if set to 0)", Usage: "Maximum number of network peers (network disabled if set to 0)",
Value: &c.cliConfig.P2P.MaxPeers, Value: &c.cliConfig.P2P.MaxPeers,
Group: "P2P",
}) })
f.Uint64Flag(&flagset.Uint64Flag{ f.Uint64Flag(&flagset.Uint64Flag{
Name: "maxpendpeers", Name: "maxpendpeers",
Usage: "Maximum number of pending connection attempts (defaults used if set to 0)", Usage: "Maximum number of pending connection attempts (defaults used if set to 0)",
Value: &c.cliConfig.P2P.MaxPendPeers, Value: &c.cliConfig.P2P.MaxPendPeers,
Group: "P2P",
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "nat", Name: "nat",
Usage: "NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>)", Usage: "NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>)",
Value: &c.cliConfig.P2P.NAT, Value: &c.cliConfig.P2P.NAT,
Group: "P2P",
}) })
f.BoolFlag(&flagset.BoolFlag{ f.BoolFlag(&flagset.BoolFlag{
Name: "nodiscover", Name: "nodiscover",
Usage: "Disables the peer discovery mechanism (manual peer addition)", Usage: "Disables the peer discovery mechanism (manual peer addition)",
Value: &c.cliConfig.P2P.NoDiscover, Value: &c.cliConfig.P2P.NoDiscover,
Group: "P2P",
}) })
f.BoolFlag(&flagset.BoolFlag{ f.BoolFlag(&flagset.BoolFlag{
Name: "v5disc", Name: "v5disc",
Usage: "Enables the experimental RLPx V5 (Topic Discovery) mechanism", Usage: "Enables the experimental RLPx V5 (Topic Discovery) mechanism",
Value: &c.cliConfig.P2P.Discovery.V5Enabled, Value: &c.cliConfig.P2P.Discovery.V5Enabled,
Group: "P2P",
}) })
// metrics // metrics
@ -372,72 +423,86 @@ func (c *Command) Flags() *flagset.Flagset {
Name: "metrics", Name: "metrics",
Usage: "Enable metrics collection and reporting", Usage: "Enable metrics collection and reporting",
Value: &c.cliConfig.Telemetry.Enabled, Value: &c.cliConfig.Telemetry.Enabled,
Group: "Telemetry",
}) })
f.BoolFlag(&flagset.BoolFlag{ f.BoolFlag(&flagset.BoolFlag{
Name: "metrics.expensive", Name: "metrics.expensive",
Usage: "Enable expensive metrics collection and reporting", Usage: "Enable expensive metrics collection and reporting",
Value: &c.cliConfig.Telemetry.Expensive, Value: &c.cliConfig.Telemetry.Expensive,
Group: "Telemetry",
}) })
f.BoolFlag(&flagset.BoolFlag{ f.BoolFlag(&flagset.BoolFlag{
Name: "metrics.influxdb", Name: "metrics.influxdb",
Usage: "Enable metrics export/push to an external InfluxDB database (v1)", Usage: "Enable metrics export/push to an external InfluxDB database (v1)",
Value: &c.cliConfig.Telemetry.InfluxDB.V1Enabled, Value: &c.cliConfig.Telemetry.InfluxDB.V1Enabled,
Group: "Telemetry",
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "metrics.influxdb.endpoint", Name: "metrics.influxdb.endpoint",
Usage: "InfluxDB API endpoint to report metrics to", Usage: "InfluxDB API endpoint to report metrics to",
Value: &c.cliConfig.Telemetry.InfluxDB.Endpoint, Value: &c.cliConfig.Telemetry.InfluxDB.Endpoint,
Group: "Telemetry",
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "metrics.influxdb.database", Name: "metrics.influxdb.database",
Usage: "InfluxDB database name to push reported metrics to", Usage: "InfluxDB database name to push reported metrics to",
Value: &c.cliConfig.Telemetry.InfluxDB.Database, Value: &c.cliConfig.Telemetry.InfluxDB.Database,
Group: "Telemetry",
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "metrics.influxdb.username", Name: "metrics.influxdb.username",
Usage: "Username to authorize access to the database", Usage: "Username to authorize access to the database",
Value: &c.cliConfig.Telemetry.InfluxDB.Username, Value: &c.cliConfig.Telemetry.InfluxDB.Username,
Group: "Telemetry",
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "metrics.influxdb.password", Name: "metrics.influxdb.password",
Usage: "Password to authorize access to the database", Usage: "Password to authorize access to the database",
Value: &c.cliConfig.Telemetry.InfluxDB.Password, Value: &c.cliConfig.Telemetry.InfluxDB.Password,
Group: "Telemetry",
}) })
f.MapStringFlag(&flagset.MapStringFlag{ f.MapStringFlag(&flagset.MapStringFlag{
Name: "metrics.influxdb.tags", Name: "metrics.influxdb.tags",
Usage: "Comma-separated InfluxDB tags (key/values) attached to all measurements", Usage: "Comma-separated InfluxDB tags (key/values) attached to all measurements",
Value: &c.cliConfig.Telemetry.InfluxDB.Tags, Value: &c.cliConfig.Telemetry.InfluxDB.Tags,
Group: "Telemetry",
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "metrics.prometheus-addr", Name: "metrics.prometheus-addr",
Usage: "Address for Prometheus Server", Usage: "Address for Prometheus Server",
Value: &c.cliConfig.Telemetry.PrometheusAddr, Value: &c.cliConfig.Telemetry.PrometheusAddr,
Group: "Telemetry",
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "metrics.opencollector-endpoint", Name: "metrics.opencollector-endpoint",
Usage: "OpenCollector Endpoint (host:port)", Usage: "OpenCollector Endpoint (host:port)",
Value: &c.cliConfig.Telemetry.OpenCollectorEndpoint, Value: &c.cliConfig.Telemetry.OpenCollectorEndpoint,
Group: "Telemetry",
}) })
// influx db v2 // influx db v2
f.BoolFlag(&flagset.BoolFlag{ f.BoolFlag(&flagset.BoolFlag{
Name: "metrics.influxdbv2", Name: "metrics.influxdbv2",
Usage: "Enable metrics export/push to an external InfluxDB v2 database", Usage: "Enable metrics export/push to an external InfluxDB v2 database",
Value: &c.cliConfig.Telemetry.InfluxDB.V2Enabled, Value: &c.cliConfig.Telemetry.InfluxDB.V2Enabled,
Group: "Telemetry",
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "metrics.influxdb.token", Name: "metrics.influxdb.token",
Usage: "Token to authorize access to the database (v2 only)", Usage: "Token to authorize access to the database (v2 only)",
Value: &c.cliConfig.Telemetry.InfluxDB.Token, Value: &c.cliConfig.Telemetry.InfluxDB.Token,
Group: "Telemetry",
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "metrics.influxdb.bucket", Name: "metrics.influxdb.bucket",
Usage: "InfluxDB bucket name to push reported metrics to (v2 only)", Usage: "InfluxDB bucket name to push reported metrics to (v2 only)",
Value: &c.cliConfig.Telemetry.InfluxDB.Bucket, Value: &c.cliConfig.Telemetry.InfluxDB.Bucket,
Group: "Telemetry",
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "metrics.influxdb.organization", Name: "metrics.influxdb.organization",
Usage: "InfluxDB organization name (v2 only)", Usage: "InfluxDB organization name (v2 only)",
Value: &c.cliConfig.Telemetry.InfluxDB.Organization, Value: &c.cliConfig.Telemetry.InfluxDB.Organization,
Group: "Telemetry",
}) })
// account // account
@ -445,21 +510,25 @@ func (c *Command) Flags() *flagset.Flagset {
Name: "unlock", Name: "unlock",
Usage: "Comma separated list of accounts to unlock", Usage: "Comma separated list of accounts to unlock",
Value: &c.cliConfig.Accounts.Unlock, Value: &c.cliConfig.Accounts.Unlock,
Group: "Account Management",
}) })
f.StringFlag(&flagset.StringFlag{ f.StringFlag(&flagset.StringFlag{
Name: "password", Name: "password",
Usage: "Password file to use for non-interactive password input", Usage: "Password file to use for non-interactive password input",
Value: &c.cliConfig.Accounts.PasswordFile, Value: &c.cliConfig.Accounts.PasswordFile,
Group: "Account Management",
}) })
f.BoolFlag(&flagset.BoolFlag{ f.BoolFlag(&flagset.BoolFlag{
Name: "allow-insecure-unlock", Name: "allow-insecure-unlock",
Usage: "Allow insecure account unlocking when account-related RPCs are exposed by http", Usage: "Allow insecure account unlocking when account-related RPCs are exposed by http",
Value: &c.cliConfig.Accounts.AllowInsecureUnlock, Value: &c.cliConfig.Accounts.AllowInsecureUnlock,
Group: "Account Management",
}) })
f.BoolFlag(&flagset.BoolFlag{ f.BoolFlag(&flagset.BoolFlag{
Name: "lightkdf", Name: "lightkdf",
Usage: "Reduce key-derivation RAM & CPU usage at some expense of KDF strength", Usage: "Reduce key-derivation RAM & CPU usage at some expense of KDF strength",
Value: &c.cliConfig.Accounts.UseLightweightKDF, Value: &c.cliConfig.Accounts.UseLightweightKDF,
Group: "Account Management",
}) })
// grpc // grpc

View file

@ -14,6 +14,15 @@ type StatusCommand struct {
*Meta2 *Meta2
} }
// MarkDown implements cli.MarkDown interface
func (p *StatusCommand) MarkDown() string {
items := []string{
"# Status",
"The ```status``` command outputs the status of the client.",
}
return strings.Join(items, "\n\n")
}
// Help implements the cli.Command interface // Help implements the cli.Command interface
func (p *StatusCommand) Help() string { func (p *StatusCommand) Help() string {
return `Usage: bor status return `Usage: bor status

View file

@ -1,6 +1,8 @@
package cli package cli
import ( import (
"strings"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@ -10,6 +12,24 @@ type VersionCommand struct {
UI cli.Ui UI cli.Ui
} }
// MarkDown implements cli.MarkDown interface
func (d *VersionCommand) MarkDown() string {
examples := []string{
"## Usage",
CodeBlock([]string{
"$ bor version",
"0.2.9-stable",
}),
}
items := []string{
"# Version",
"The ```bor version``` command outputs the version of the binary.",
}
items = append(items, examples...)
return strings.Join(items, "\n\n")
}
// Help implements the cli.Command interface // Help implements the cli.Command interface
func (c *VersionCommand) Help() string { func (c *VersionCommand) Help() string {
return `Usage: bor version return `Usage: bor version