diff --git a/.gitignore b/.gitignore index e6bffed..f0c3d20 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,10 @@ docs/public docs/content/signaldctl +# man page files generated for the debian package +*.1 +debian/manpages + # Binaries for programs and plugins *.exe *.exe~ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2589492..e209f79 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -53,6 +53,9 @@ build:x86:deb: - apt-get install -y git-buildpackage dh-golang golang-any golang-github-spf13-cobra-dev golang-github-spf13-viper-dev - apt-get install -y ./*.deb && rm -vf *.deb script: + - echo "generating man pages" + - go run ./cmd/signaldctl doc -o man + - ls *.1 > debian/manpages - gbp dch --ignore-branch --debian-tag="%(version)s" --git-author --new-version="$(git describe --abbrev=0)+git$(date +%Y-%m-%d)r$(git rev-parse --short=8 HEAD).$(git rev-list $(git describe --abbrev=0)..HEAD --count)" - dpkg-buildpackage -us -uc -b - mv ../*.deb . @@ -68,6 +71,7 @@ build:x86:deb: artifacts: paths: - "*.deb" + - "*.1" expire_in: 1 month publish deb: @@ -96,7 +100,7 @@ pages: - apt-get update && apt-get install -y hugo script: - mkdir -p docs/content/signaldctl - - SIGNALDCTL_PUBLIC_DOC_MODE=on ./signaldctl doc + - SIGNALDCTL_PUBLIC_DOC_MODE=on ./signaldctl doc -o md ./docs/content/signaldctl - cd docs - hugo - mv public ../ diff --git a/cmd/signaldctl/cmd/doc.go b/cmd/signaldctl/cmd/doc.go index 0276bd0..d3c6e7f 100644 --- a/cmd/signaldctl/cmd/doc.go +++ b/cmd/signaldctl/cmd/doc.go @@ -32,8 +32,20 @@ var DocCmd = &cobra.Command{ Aliases: []string{"docs"}, Hidden: true, Annotations: map[string]string{common.AnnotationNoSocketConnection: "true"}, - Run: func(_ *cobra.Command, _ []string) { - err := doc.GenMarkdownTreeCustom(RootCmd, "./docs/content/signaldctl", filePrepender, linkHandler) + Run: func(_ *cobra.Command, args []string) { + var err error + outpath := "./" + if len(args) > 0 { + outpath = args[0] + } + switch common.OutputFormat { + case common.OutputFormatMan: + err = doc.GenManTree(RootCmd, &doc.GenManHeader{Title: "signaldctl"}, outpath) + case common.OutputFormatMarkdown: + err = doc.GenMarkdownTreeCustom(RootCmd, outpath, filePrepender, linkHandler) + case common.OutputFormatYAML: + err = doc.GenYamlTree(RootCmd, outpath) + } if err != nil { log.Fatal(err) } diff --git a/cmd/signaldctl/common/signald.go b/cmd/signaldctl/common/signald.go index 2e9569f..1b2ffa3 100644 --- a/cmd/signaldctl/common/signald.go +++ b/cmd/signaldctl/common/signald.go @@ -7,12 +7,14 @@ import ( ) const ( - OutputFormatDefault = "default" - OutputFormatCSV = "csv" - OutputFormatTable = "table" - OutputFormatJSON = "json" - OutputFormatYAML = "yaml" - OutputFormatQR = "qr" + OutputFormatDefault = "default" + OutputFormatCSV = "csv" + OutputFormatTable = "table" + OutputFormatJSON = "json" + OutputFormatYAML = "yaml" + OutputFormatQR = "qr" + OutputFormatMarkdown = "md" + OutputFormatMan = "man" AnnotationNoSocketConnection = "no-socket" ) diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..aee0b0e --- /dev/null +++ b/docs/README.md @@ -0,0 +1 @@ +# [docs are here](https://signald.gitlab.io/signald-go/signaldctl/) \ No newline at end of file