Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: docs cmd to generate zetacored CLI docs #960

Merged
merged 36 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
eac319b
feat: generate zetacored CLI docs
fadeev Aug 14, 2023
ccefa4a
refactor: move docs cmd into docs.go
fadeev Aug 14, 2023
a7134ab
refactor: rename makefile target
fadeev Aug 14, 2023
612fdc3
remove flags.LineBreak,
fadeev Aug 14, 2023
43e1706
AppName
fadeev Aug 14, 2023
aaee31a
make generate
fadeev Aug 14, 2023
7e7a497
Replace home dir with ~ to make the check pass
fadeev Aug 14, 2023
51f0e41
replace [appd] with zetacored
fadeev Aug 14, 2023
fd35710
replace IP
fadeev Aug 14, 2023
4123d1d
remove (default ...)
fadeev Aug 14, 2023
8a1d77e
Update cmd/zetacored/docs.go
fadeev Aug 14, 2023
0fe9b3c
Merge branch 'develop' into feat/zetacored-docs
fadeev Aug 14, 2023
f8f99ec
Merge branch 'develop' into feat/zetacored-docs
fadeev Aug 15, 2023
528c57c
make generate
fadeev Aug 15, 2023
091406b
Merge branch 'develop' into feat/zetacored-docs
fadeev Aug 15, 2023
66cef14
Merge branch 'develop' into feat/zetacored-docs
fadeev Aug 17, 2023
c52a8dd
Merge branch 'develop' into feat/zetacored-docs
fadeev Aug 21, 2023
3f2334b
make generate
fadeev Aug 21, 2023
e87cd1b
Merge branch 'develop' into feat/zetacored-docs
fadeev Aug 22, 2023
20aaff2
make generate
fadeev Aug 22, 2023
37f25dd
Merge branch 'develop' into feat/zetacored-docs
fadeev Aug 23, 2023
58a8d61
Merge branch 'develop' into feat/zetacored-docs
fadeev Aug 25, 2023
f77aa9e
Merge branch 'develop' into feat/zetacored-docs
fadeev Aug 29, 2023
1cbf49d
merge develop
fadeev Sep 26, 2023
b82bc94
Merge branch 'develop' into feat/zetacored-docs
fadeev Sep 26, 2023
02a362f
make generate
fadeev Sep 26, 2023
d76cb82
Merge branch 'develop' into feat/zetacored-docs
fadeev Sep 29, 2023
ad9cb6d
Merge branch 'develop' into feat/zetacored-docs
fadeev Oct 1, 2023
4017e6d
Merge branch 'develop' into feat/zetacored-docs
fadeev Oct 27, 2023
3c411ef
make generate
fadeev Oct 27, 2023
cb9d7b4
Merge branch 'develop' into feat/zetacored-docs
fadeev Oct 30, 2023
119e746
fix gosec
lumtis Oct 30, 2023
00b49dc
fix makefile
lumtis Oct 30, 2023
5fe10c1
remove last line
lumtis Oct 30, 2023
71e728e
use nosec for params
lumtis Oct 30, 2023
5e6d72d
fix gosec in docs.go
lumtis Oct 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions .github/workflows/generate-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,8 @@ jobs:
run: |
echo "$HOME/go/bin" >> $GITHUB_PATH

- name: Generate Go code from proto files
run: make proto

- name: Generate OpenAPI
run: make openapi

- name: Generate Module Documentation
run: make specs
- name: Generate Go code, docs and specs
run: make generate

- name: Check for changes
run: |
Expand Down
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,18 @@ specs:
@go run ./scripts/gen-spec.go
.PHONY: specs

docs-zetacored:
@echo "--> Generating zetacored documentation"
@bash ./scripts/gen-docs-zetacored.sh
.PHONY: docs-zetacored

generate: proto openapi specs docs-zetacored
.PHONY: generate

mocks:
@echo "--> Generating mocks"
@bash ./scripts/mocks-generate.sh

generate: proto openapi specs
.PHONY: generate
.PHONY: mocks

###############################################################################
### Docker Images ###
Expand Down
7 changes: 5 additions & 2 deletions cmd/zetacore_utils/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ func main() {

distributionList := make([]TokenDistribution, len(addresses))
for i, address := range addresses {
cmd := exec.Command("zetacored", "q", "bank", "balances", address, "--output", "json", "--denom", "azeta", "--node", node) // #nosec G204
// #nosec G204
cmd := exec.Command("zetacored", "q", "bank", "balances", address, "--output", "json", "--denom", "azeta", "--node", node)
output, err := cmd.CombinedOutput()
if err != nil {
fmt.Println(cmd.String())
Expand Down Expand Up @@ -85,6 +86,7 @@ func main() {
args = append(args, []string{distributionList[0].TokensDistributed.String(), "--keyring-backend", "test", "--chain-id", chainID, "--yes",
"--broadcast-mode", broadcastMode, "--gas=auto", "--gas-adjustment=2", "--gas-prices=0.001azeta", "--node", node}...)

// #nosec G204
cmd := exec.Command("zetacored", args...)
output, err := cmd.CombinedOutput()
if err != nil {
Expand All @@ -97,7 +99,8 @@ func main() {
time.Sleep(7 * time.Second)

for i, address := range addresses {
cmd := exec.Command("zetacored", "q", "bank", "balances", address, "--output", "json", "--denom", "azeta", "--node", node) // #nosec G204
// #nosec G204
cmd := exec.Command("zetacored", "q", "bank", "balances", address, "--output", "json", "--denom", "azeta", "--node", node)
output, err := cmd.CombinedOutput()
if err != nil {
fmt.Println(cmd.String())
Expand Down
1 change: 1 addition & 0 deletions cmd/zetacored/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func SetBech32Prefixes(config *sdk.Config) {
const (
DisplayDenom = "zeta"
BaseDenom = "azeta"
AppName = "zetacored"
)

// RegisterDenoms registers the base and display denominations to the SDK.
Expand Down
49 changes: 49 additions & 0 deletions cmd/zetacored/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package main

import (
"os"

"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)

func docsCmd(cmd *cobra.Command, args []string) error {
var path string

// If path is provided as an argument, use it. Else, get from flag.
if len(args) > 0 {
path = args[0]
} else {
var err error
path, err = cmd.Flags().GetString("path")
if err != nil {
return err
}
}

if _, err := os.Stat(path); os.IsNotExist(err) {
err = os.MkdirAll(path, 0750)
if err != nil {
return err
}
}

err := doc.GenMarkdownTree(cmd.Root(), path)
if err != nil {
return err
}
return nil
}

func docsCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "docs [path]",
Short: "Generate markdown documentation for zetacored",
RunE: docsCmd,
fadeev marked this conversation as resolved.
Show resolved Hide resolved
Args: cobra.MaximumNArgs(1),
}

cmd.Flags().String("path", "docs/cli/zetacored", "Path where the docs will be generated")

return cmd
}
5 changes: 2 additions & 3 deletions cmd/zetacored/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/cosmos/cosmos-sdk/snapshots"
"github.com/cosmos/cosmos-sdk/store"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
Expand Down Expand Up @@ -69,7 +68,7 @@ func NewRootCmd() (*cobra.Command, appparams.EncodingConfig) {
WithViper(EnvPrefix)

rootCmd := &cobra.Command{
Use: version.AppName,
Use: zetacoredconfig.AppName,
Short: "Zetacore Daemon (server)",
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
// set the default command outputs
Expand Down Expand Up @@ -152,6 +151,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig appparams.EncodingConfig
rpc.StatusCommand(),
queryCommand(),
txCommand(),
docsCommand(),
ethermintclient.KeyCommands(app.DefaultNodeHome),
)

Expand Down Expand Up @@ -206,7 +206,6 @@ func txCommand() *cobra.Command {
authcmd.GetMultiSignCommand(),
authcmd.GetMultiSignBatchCmd(),
authcmd.GetValidateSignaturesCommand(),
flags.LineBreak,
authcmd.GetBroadcastCommand(),
authcmd.GetEncodeCommand(),
authcmd.GetDecodeCommand(),
Expand Down
42 changes: 42 additions & 0 deletions docs/cli/zetacored/zetacored.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
## zetacored

Zetacore Daemon (server)

### Options

```
-h, --help help for zetacored
--home string directory for config and data
--log_format string The logging format (json|plain)
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic)
--trace print out full stack trace on errors
```

### SEE ALSO

* [zetacored add-genesis-account](zetacored_add-genesis-account.md) - Add a genesis account to genesis.json
* [zetacored add-observer-list](zetacored_add-observer-list.md) - Add a list of observers to the observer mapper ,default path is ~/.zetacored/os_info/observer_info.json
* [zetacored addr-conversion](zetacored_addr-conversion.md) - convert a zeta1xxx address to validator operator address zetavaloper1xxx
* [zetacored collect-gentxs](zetacored_collect-gentxs.md) - Collect genesis txs and output a genesis.json file
* [zetacored collect-observer-info](zetacored_collect-observer-info.md) - collect observer info from a folder , default path is ~/.zetacored/os_info/

* [zetacored config](zetacored_config.md) - Create or query an application CLI configuration file
* [zetacored debug](zetacored_debug.md) - Tool for helping with debugging your application
* [zetacored docs](zetacored_docs.md) - Generate markdown documentation for zetacored
* [zetacored export](zetacored_export.md) - Export state to JSON
* [zetacored gentx](zetacored_gentx.md) - Generate a genesis tx carrying a self delegation
* [zetacored get-pubkey](zetacored_get-pubkey.md) - Get you node account
* [zetacored index-eth-tx](zetacored_index-eth-tx.md) - Index historical eth txs
* [zetacored init](zetacored_init.md) - Initialize private validator, p2p, genesis, and application configuration files
* [zetacored keys](zetacored_keys.md) - Manage your application's keys
* [zetacored query](zetacored_query.md) - Querying subcommands
* [zetacored rollback](zetacored_rollback.md) - rollback cosmos-sdk and tendermint state by one height
* [zetacored rosetta](zetacored_rosetta.md) - spin up a rosetta server
* [zetacored start](zetacored_start.md) - Run the full node
* [zetacored status](zetacored_status.md) - Query remote node for status
* [zetacored tendermint](zetacored_tendermint.md) - Tendermint subcommands
* [zetacored testnet](zetacored_testnet.md) - subcommands for starting or configuring local testnets
* [zetacored tx](zetacored_tx.md) - Transactions subcommands
* [zetacored validate-genesis](zetacored_validate-genesis.md) - validates the genesis file at the default location or at the location passed as an arg
* [zetacored version](zetacored_version.md) - Print the application binary version information

44 changes: 44 additions & 0 deletions docs/cli/zetacored/zetacored_add-genesis-account.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# add-genesis-account

Add a genesis account to genesis.json

### Synopsis

Add a genesis account to genesis.json. The provided account must specify
the account address or key name and a list of initial coins. If a key name is given,
the address will be looked up in the local Keybase. The list of initial tokens must
contain valid denominations. Accounts may optionally be supplied with vesting parameters.


```
zetacored add-genesis-account [address_or_key_name] [coin][,[coin]] [flags]
```

### Options

```
--grpc-addr string the gRPC endpoint to use for this chain
--grpc-insecure allow gRPC over insecure channels, if not TLS the server must use TLS
--height int Use a specific height to query state at (this can error if the node is pruning state)
-h, --help help for add-genesis-account
--home string The application home directory
--keyring-backend string Select keyring's backend (os|file|kwallet|pass|test)
--node string [host]:[port] to Tendermint RPC interface for this chain
-o, --output string Output format (text|json)
--vesting-amount string amount of coins for vesting accounts
--vesting-end-time int schedule end time (unix epoch) for vesting accounts
--vesting-start-time int schedule start time (unix epoch) for vesting accounts
```

### Options inherited from parent commands

```
--log_format string The logging format (json|plain)
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic)
--trace print out full stack trace on errors
```

### SEE ALSO

* [zetacored](zetacored.md) - Zetacore Daemon (server)

29 changes: 29 additions & 0 deletions docs/cli/zetacored/zetacored_add-observer-list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# add-observer-list

Add a list of observers to the observer mapper ,default path is ~/.zetacored/os_info/observer_info.json

```
zetacored add-observer-list [observer-list.json] [flags]
```

### Options

```
-h, --help help for add-observer-list
--keygen-block int set keygen block , default is 20 (default 20)
--tss-pubkey string set TSS pubkey if using older keygen
```

### Options inherited from parent commands

```
--home string directory for config and data
--log_format string The logging format (json|plain)
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic)
--trace print out full stack trace on errors
```

### SEE ALSO

* [zetacored](zetacored.md) - Zetacore Daemon (server)

35 changes: 35 additions & 0 deletions docs/cli/zetacored/zetacored_addr-conversion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# addr-conversion

convert a zeta1xxx address to validator operator address zetavaloper1xxx

### Synopsis


read a zeta1xxx or zetavaloper1xxx address and convert it to the other type;
it always outputs three lines; the first line is the zeta1xxx address, the second line is the zetavaloper1xxx address
and the third line is the ethereum address.


```
zetacored addr-conversion [zeta address] [flags]
```

### Options

```
-h, --help help for addr-conversion
```

### Options inherited from parent commands

```
--home string directory for config and data
--log_format string The logging format (json|plain)
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic)
--trace print out full stack trace on errors
```

### SEE ALSO

* [zetacored](zetacored.md) - Zetacore Daemon (server)

28 changes: 28 additions & 0 deletions docs/cli/zetacored/zetacored_collect-gentxs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# collect-gentxs

Collect genesis txs and output a genesis.json file

```
zetacored collect-gentxs [flags]
```

### Options

```
--gentx-dir string override default "gentx" directory from which collect and execute genesis transactions; default [--home]/config/gentx/
-h, --help help for collect-gentxs
--home string The application home directory
```

### Options inherited from parent commands

```
--log_format string The logging format (json|plain)
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic)
--trace print out full stack trace on errors
```

### SEE ALSO

* [zetacored](zetacored.md) - Zetacore Daemon (server)

28 changes: 28 additions & 0 deletions docs/cli/zetacored/zetacored_collect-observer-info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# collect-observer-info

collect observer info from a folder , default path is ~/.zetacored/os_info/


```
zetacored collect-observer-info [folder] [flags]
```

### Options

```
-h, --help help for collect-observer-info
```

### Options inherited from parent commands

```
--home string directory for config and data
--log_format string The logging format (json|plain)
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic)
--trace print out full stack trace on errors
```

### SEE ALSO

* [zetacored](zetacored.md) - Zetacore Daemon (server)

27 changes: 27 additions & 0 deletions docs/cli/zetacored/zetacored_config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# config

Create or query an application CLI configuration file

```
zetacored config [key] [value] [flags]
```

### Options

```
-h, --help help for config
```

### Options inherited from parent commands

```
--home string directory for config and data
--log_format string The logging format (json|plain)
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic)
--trace print out full stack trace on errors
```

### SEE ALSO

* [zetacored](zetacored.md) - Zetacore Daemon (server)

Loading
Loading