Skip to content

Commit

Permalink
fix(gen-cli-docs): fix flag parsing and re-gen (#4084)
Browse files Browse the repository at this point in the history
* fix(gen-cli-docs): fix flag parsing and re-gen

* hide temp flag
  • Loading branch information
julienrbrt authored Apr 18, 2024
1 parent 9179104 commit 47fe063
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/docs/08-references/01-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Ignite CLI offers everything you need to scaffold, test, build, and launch your

**Synopsis**

Ignite CLI is a tool for creating sovereign blockchains built with Cosmos SDK, the worlds
Ignite CLI is a tool for creating sovereign blockchains built with Cosmos SDK, the world's
most popular modular blockchain framework. Ignite CLI offers everything you need to scaffold,
test, build, and launch your blockchain.

Expand Down
19 changes: 13 additions & 6 deletions ignite/internal/tools/gen-cli-docs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"bufio"
"bytes"
"context"
"flag"
"fmt"
"io"
"log"
Expand All @@ -23,24 +22,25 @@ import (
"github.com/ignite/cli/v29/ignite/services/plugin"
)

const head = `---
const (
head = `---
description: Ignite CLI docs.
---
# CLI commands
Documentation for Ignite CLI.
`
outFlag = "out"
)

func main() {
outPath := flag.String("out", ".", ".md file path to place Ignite CLI docs inside")
flag.Parse()
if err := run(*outPath); err != nil {
if err := run(); err != nil {
log.Fatal(err)
}
}

func run(outPath string) error {
func run() error {
// We want to have documentation for commands that are implemented in plugins.
// To do that, we need to add the related plugins in the config.
// To avoid conflicts with user config, set an alternate config dir in tmp.
Expand Down Expand Up @@ -71,13 +71,20 @@ func run(outPath string) error {
return err
}
defer cleanUp()
cmd.Flags().String(outFlag, ".", ".md file path to place Ignite CLI docs inside")
cmd.Flags().MarkHidden(outFlag)

// Run ExecuteC so cobra adds the completion command.
cmd, err = cmd.ExecuteC()
if err != nil {
return err
}

outPath, err := cmd.Flags().GetString(outFlag)
if err != nil {
return nil
}

return generate(cmd, outPath)
}

Expand Down

0 comments on commit 47fe063

Please sign in to comment.