1 Star 0 Fork 0

Lucky.麒麟 / goboot

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
man_docs.md 519 Bytes
一键复制 编辑 原始数据 按行查看 历史
2354713722@qq.com 提交于 2023-09-18 17:59 . init

Generating Man Pages For Your Own cobra.Command

Generating man pages from a cobra command is incredibly easy. An example is as follows:

package main

import (
	"log"

	"github.com/spf13/cobra"
	"github.com/spf13/cobra/doc"
)

func main() {
	cmd := &cobra.Command{
		Use:   "test",
		Short: "my test program",
	}
	header := &doc.GenManHeader{
		Title: "MINE",
		Section: "3",
	}
	err := doc.GenManTree(cmd, header, "/tmp")
	if err != nil {
		log.Fatal(err)
	}
}

That will get you a man page /tmp/test.3

Go
1
https://gitee.com/molonglove/goboot.git
git@gitee.com:molonglove/goboot.git
molonglove
goboot
goboot
v1.0.4

搜索帮助

53164aa7 5694891 3bd8fe86 5694891