Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
Add docs cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
foxytanuki committed Nov 12, 2023
1 parent 7b184d5 commit fafde85
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ release/
.idea/
.vscode/
.DS_Store
docs/static/cmd
6 changes: 6 additions & 0 deletions cmd/myceld/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
"github.com/mycel-domain/mycel/app"
appparams "github.com/mycel-domain/mycel/app/params"
"github.com/mycel-domain/mycel/cmd/myceld/dns"
"github.com/mycel-domain/mycel/cmd/myceld/docs"
)

// NewRootCmd creates a new root command for a Cosmos SDK application
Expand Down Expand Up @@ -159,6 +160,11 @@ func initRootCmd(
rootCmd.AddCommand(
dns.DnsCommand(),
)

// add docs command
rootCmd.AddCommand(
docs.DocsCommand(rootCmd),
)
}

// queryCommand returns the sub-command to send queries to the app
Expand Down
29 changes: 29 additions & 0 deletions cmd/myceld/docs/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package docs

import (
"fmt"
"os"

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

func DocsCommand(rootCmd *cobra.Command) *cobra.Command {
cmd := &cobra.Command{
Use: "docs",
Short: "Generate markdowns docs for all myceld commands",
RunE: func(cmd *cobra.Command, _ []string) (err error) {
path := "docs/static/cmd"

if err := os.MkdirAll(path, os.FileMode(0644)); err != nil {
fmt.Println(err)
os.Exit(1)
}

fmt.Printf("Export cmd docs to: %s", path)
err = doc.GenMarkdownTree(rootCmd, path)
return err
},
}
return cmd
}

0 comments on commit fafde85

Please sign in to comment.