Remove From

Signed-off-by: jolheiser <john.olheiser@gmail.com>
main v0.0.2
jolheiser 2021-10-31 16:04:40 -05:00
parent 4a13872104
commit da2620a37f
Signed by: jolheiser
GPG Key ID: B853ADA5DA7BBF7A
5 changed files with 40 additions and 7 deletions

View File

@ -9,6 +9,39 @@ With `ffmd` you can generate markdown docs for both `flag.FlagSet` and `ffcli.Co
Check out [examples](examples) for some sample generated docs.
## Generate your docs
```go
//go:build generate
// +build generate
package main
import (
"os"
"go.jolheiser.com/ffmd"
)
func main() {
fi, err := os.Create("docs.md")
if err != nil {
panic(err)
}
defer fi.Close()
// cmd is the ffcli.Command
md, err := ffmd.Command(cmd)
if err != nil {
panic(err)
}
if _, err := fi.WriteString(md); err != nil {
panic(err)
}
}
```
## License

View File

@ -23,7 +23,7 @@ func main() {
fs.Duration("duration-flag", 0, "Duration flag with no default")
fs.Duration("duration-flag-default", time.Minute*5, "Duration flag with default")
md, err := ffmd.FromFlagSet(fs)
md, err := ffmd.FlagSet(fs)
if err != nil {
panic(err)
}

View File

@ -62,7 +62,7 @@ func main() {
cmd2.Subcommands = []*ffcli.Command{cmd3, cmd5}
cmd3.Subcommands = []*ffcli.Command{cmd4}
md, err := ffmd.FromCommand(cmd)
md, err := ffmd.Command(cmd)
if err != nil {
panic(err)
}

View File

@ -31,7 +31,7 @@ func main() {
Subcommands: nil,
}
md, err := ffmd.FromCommand(cmd)
md, err := ffmd.Command(cmd)
if err != nil {
panic(err)
}

View File

@ -19,13 +19,13 @@ var (
Template = template.Must(template.New("").Parse(ffmdtmpl))
)
// FromCommand turns a ffcli.Command into markdown
func FromCommand(cmd *ffcli.Command) (string, error) {
// Command turns a ffcli.Command into markdown
func Command(cmd *ffcli.Command) (string, error) {
return fromCommand(cmd, 1)
}
// FromFlagSet turns a flag.FlagSet into markdown
func FromFlagSet(fs *flag.FlagSet) (string, error) {
// FlagSet turns a flag.FlagSet into markdown
func FlagSet(fs *flag.FlagSet) (string, error) {
return flagSetCommand(fs, 2).Markdown()
}