2021-10-29 22:11:34 +00:00
|
|
|
# ffmd
|
|
|
|
|
|
|
|
[![Go Reference](https://pkg.go.dev/badge/go.jolheiser.com/ffmd.svg)](https://pkg.go.dev/go.jolheiser.com/ffmd)
|
|
|
|
|
2021-10-30 21:51:30 +00:00
|
|
|
One of the things that I really liked about [urfave/cli](https://github.com/urfave/cli) was that it could
|
|
|
|
generate markdown docs for my commands.
|
|
|
|
|
|
|
|
With `ffmd` you can generate markdown docs for both `flag.FlagSet` and `ffcli.Command` (with any amount of sub-commands).
|
|
|
|
|
|
|
|
Check out [examples](examples) for some sample generated docs.
|
|
|
|
|
2021-10-31 21:04:40 +00:00
|
|
|
## 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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
```
|
2021-10-30 21:51:30 +00:00
|
|
|
|
2021-10-29 22:11:34 +00:00
|
|
|
## License
|
|
|
|
|
|
|
|
[MIT](LICENSE)
|