-
Notifications
You must be signed in to change notification settings - Fork 489
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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`.
- Loading branch information
Showing
44 changed files
with
686 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
|
||
# Account import | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
|
||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
|
||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
|
||
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Fingerprint | ||
|
||
Display the system fingerprint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
|
||
# Peers add | ||
|
||
The ```peers add <enode>``` command joins the local client to another remote peer. | ||
|
||
## Arguments | ||
## Options | ||
|
||
- ```address```: Address of the grpc endpoint | ||
|
||
- ```trusted```: Whether the peer is added as a trusted peer. | ||
- ```trusted```: Add the peer as a trusted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
|
||
# Peers list | ||
# Peers add | ||
|
||
The ```peers list``` command lists the connected peers. | ||
|
||
## Options | ||
|
||
- ```address```: Address of the grpc endpoint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
|
||
# Peers remove | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
|
||
# Peers status | ||
|
||
The ```peers status <peer id>``` command displays the status of a peer by its id. | ||
|
||
## Options | ||
|
||
- ```address```: Address of the grpc endpoint |
Oops, something went wrong.