Skip to content

Commit

Permalink
feat: add support for examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jon4hz committed Oct 15, 2022
1 parent 06c8d8e commit 033ae1c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var (
RunE: func(cmd *cobra.Command, agrs []string) error {
return nil
},
Example: "mango --help",
}

oneCmd = &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/muesli/mango-cobra
go 1.17

require (
github.com/muesli/mango v0.1.0
github.com/muesli/mango v0.2.0
github.com/muesli/mango-pflag v0.1.0
github.com/muesli/roff v0.1.0
github.com/spf13/cobra v1.5.0
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/muesli/mango v0.1.0 h1:DZQK45d2gGbql1arsYA4vfg4d7I9Hfx5rX/GCmzsAvI=
github.com/muesli/mango v0.1.0/go.mod h1:5XFpbC8jY5UUv89YQciiXNlbi+iJgt29VDC5xbzrLL4=
github.com/muesli/mango v0.2.0 h1:iNNc0c5VLQ6fsMgAqGQofByNUBH2Q2nEbD6TaI+5yyQ=
github.com/muesli/mango v0.2.0/go.mod h1:5XFpbC8jY5UUv89YQciiXNlbi+iJgt29VDC5xbzrLL4=
github.com/muesli/mango-pflag v0.1.0 h1:UADqbYgpUyRoBja3g6LUL+3LErjpsOwaC9ywvBWe7Sg=
github.com/muesli/mango-pflag v0.1.0/go.mod h1:YEQomTxaCUp8PrbhFh10UfbhbQrM/xJ4i2PB8VTLLW0=
github.com/muesli/roff v0.1.0 h1:YD0lalCotmYuF5HhZliKWlIx7IEhiXeSfq7hNjFqGF8=
Expand Down
2 changes: 2 additions & 0 deletions mcobra.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ func addCommandTree(m *mango.ManPage, c *cobra.Command, parent *mango.Command) e
if parent == nil {
// set root command
item = mango.NewCommand(c.Name(), "", "")
item.Example = c.Example
m.Root = *item
} else {
item = mango.NewCommand(c.Name(), c.Short, c.Use)
item.Example = c.Example
if err := parent.AddCommand(item); err != nil {
return err
}
Expand Down

0 comments on commit 033ae1c

Please sign in to comment.