Skip to content

Commit

Permalink
docs: Add generated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Jul 12, 2024
1 parent 49a8775 commit 6441555
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ repos:
- id: go-mod-tidy-repo
- id: golangci-lint-mod
args: [--fix]

- repo: local
hooks:
- id: usage-docs
name: usage-docs
entry: go run -tags rand_insecure_for_docs ./internal/generate/docs
language: system
pass_filenames: false
8 changes: 5 additions & 3 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import (

func New() *cobra.Command {
cmd := &cobra.Command{
Use: "cli-of-life",
RunE: run,
Args: cobra.NoArgs,
Use: "cli-of-life",
Short: "Play Conway's Game of Life in your terminal",
RunE: run,
Args: cobra.NoArgs,

ValidArgsFunction: cobra.NoFileCompletions,
DisableAutoGenTag: true,
}

cmd.Flags().StringP(config.FileFlag, "f", "", "Loads a pattern file on startup")
Expand Down
17 changes: 17 additions & 0 deletions docs/cli-of-life.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## cli-of-life

Play Conway's Game of Life in your terminal

```
cli-of-life [flags]
```

### Options

```
--completion string Output command-line completion code for the specified shell. Can be 'bash', 'zsh', 'fish', or 'powershell'.
-f, --file string Loads a pattern file on startup
--file-format string File format (one of: auto, rle, plaintext) (default "auto")
-h, --help help for cli-of-life
```

2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require (
github.com/charmbracelet/x/input v0.1.0 // indirect
github.com/charmbracelet/x/term v0.1.1 // indirect
github.com/charmbracelet/x/windows v0.1.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand All @@ -29,6 +30,7 @@ require (
github.com/muesli/termenv v0.15.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/sync v0.7.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ github.com/charmbracelet/x/term v0.1.1 h1:3cosVAiPOig+EV4X9U+3LDgtwwAoEzJjNdwbXD
github.com/charmbracelet/x/term v0.1.1/go.mod h1:wB1fHt5ECsu3mXYusyzcngVWWlu1KKUmmLhfgr/Flxw=
github.com/charmbracelet/x/windows v0.1.0 h1:gTaxdvzDM5oMa/I2ZNF7wN78X/atWemG9Wph7Ika2k4=
github.com/charmbracelet/x/windows v0.1.0/go.mod h1:GLEO/l+lizvFDBPLIOk+49gdX49L9YWMB5t+DZd0jkQ=
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -44,6 +45,7 @@ github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
Expand Down
21 changes: 21 additions & 0 deletions internal/generate/docs/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package main

import (
"os"

"github.com/gabe565/cli-of-life/cmd"
"github.com/spf13/cobra/doc"
)

func main() {
output := "./docs"

if err := os.MkdirAll(output, 0o755); err != nil {
panic(err)
}

root := cmd.New()
if err := doc.GenMarkdownTree(root, output); err != nil {
panic(err)
}
}

0 comments on commit 6441555

Please sign in to comment.