1
1
Fork 0
mirror of https://github.com/goreleaser/nfpm synced 2024-04-25 19:05:16 +02:00

feat: generate man pages (#443)

* feat: migrate to coral

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>

* feat: generate man pages

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
This commit is contained in:
Carlos Alexandro Becker 2022-02-02 23:30:46 -03:00 committed by GitHub
parent 596412c6d1
commit 13e76671c0
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 62 additions and 0 deletions

1
.gitignore vendored
View File

@ -16,3 +16,4 @@ testdata/acceptance/tmp/
completions/
.task/
cosign.*
manpages

View File

@ -5,6 +5,7 @@ before:
hooks:
- go mod tidy
- ./scripts/completions.sh
- ./scripts/manpages.sh
gomod:
proxy: true
@ -87,6 +88,7 @@ archives:
- README.md
- LICENSE.md
- completions/*
- manpages/*
brews:
- tap:
@ -103,6 +105,7 @@ brews:
bash_completion.install "completions/nfpm.bash" => "nfpm"
zsh_completion.install "completions/nfpm.zsh" => "_nfpm"
fish_completion.install "completions/nfpm.fish"
man1.install "manpages/nfpm.1.gz"
rigs:
- rig:
@ -138,6 +141,8 @@ nfpms:
dst: /usr/share/fish/completions/nfpm.fish
- src: ./completions/nfpm.zsh
dst: /usr/local/share/zsh/site-functions/_nfpm
- src: ./manpages/nfpm.1.gz
dst: /usr/share/man/man1/nfpm.1.gz
furies:
- account: goreleaser

4
go.mod
View File

@ -15,6 +15,8 @@ require (
github.com/goreleaser/fileglob v1.2.0
github.com/imdario/mergo v0.3.12
github.com/muesli/coral v1.0.0
github.com/muesli/mango-coral v1.0.0
github.com/muesli/roff v0.1.0
github.com/stretchr/testify v1.7.0
github.com/ulikunitz/xz v0.5.10
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8
@ -48,6 +50,8 @@ require (
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/muesli/mango v0.0.0-20220201014152-f7df5a1c5b4b // indirect
github.com/muesli/mango-pflag v0.0.0-20220201014449-d694870c5590 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect

8
go.sum
View File

@ -235,6 +235,14 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/muesli/coral v1.0.0 h1:odyqkoEg4aJAINOzvnjN4tUsdp+Zleccs7tRIAkkYzU=
github.com/muesli/coral v1.0.0/go.mod h1:bf91M/dkp7iHQw73HOoR9PekdTJMTD6ihJgWoDitde8=
github.com/muesli/mango v0.0.0-20220201014152-f7df5a1c5b4b h1:kGcKjlZqUNbpUjBMdIq5/RbA2gN9ypH0Tv+MNBtCgK4=
github.com/muesli/mango v0.0.0-20220201014152-f7df5a1c5b4b/go.mod h1:5XFpbC8jY5UUv89YQciiXNlbi+iJgt29VDC5xbzrLL4=
github.com/muesli/mango-coral v1.0.0 h1:OnUtvcHZ+Q2yi0B6RXm2VJVnOJVvY7G947t4ybUy868=
github.com/muesli/mango-coral v1.0.0/go.mod h1:8sxkm+gsWOnUiv5gpvtilx4OErv1nQVSJXJmNkExxBs=
github.com/muesli/mango-pflag v0.0.0-20220201014449-d694870c5590 h1:bZgkcUsck7Y6kMUcpettBv6jUck4rTrgPEBIKwFbGpM=
github.com/muesli/mango-pflag v0.0.0-20220201014449-d694870c5590/go.mod h1:o2wTF9T2N5YEx+lHxQ6R3RsUg9NH4jyaOIlnJN5KQ04=
github.com/muesli/roff v0.1.0 h1:YD0lalCotmYuF5HhZliKWlIx7IEhiXeSfq7hNjFqGF8=
github.com/muesli/roff v0.1.0/go.mod h1:pjAHQM9hdUUwm/krAfrLGgJkXJ+YuhtsfZ42kieB2Ig=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=

38
internal/cmd/man.go Normal file
View File

@ -0,0 +1,38 @@
package cmd
import (
"fmt"
"os"
"github.com/muesli/coral"
mcoral "github.com/muesli/mango-coral"
"github.com/muesli/roff"
)
type manCmd struct {
cmd *coral.Command
}
func newManCmd() *manCmd {
root := &manCmd{}
cmd := &coral.Command{
Use: "man",
Short: "Generates nfpm's command line manpages",
SilenceUsage: true,
DisableFlagsInUseLine: true,
Hidden: true,
Args: coral.NoArgs,
RunE: func(cmd *coral.Command, args []string) error {
manPage, err := mcoral.NewManPage(1, root.cmd.Root())
if err != nil {
return err
}
_, err = fmt.Fprint(os.Stdout, manPage.Build(roff.NewDocument()))
return err
},
}
root.cmd = cmd
return root
}

View File

@ -45,6 +45,7 @@ func newRootCmd(version string, exit func(int)) *rootCmd {
newInitCmd().cmd,
newPackageCmd().cmd,
newDocsCmd().cmd,
newManCmd().cmd,
newSchemaCmd().cmd,
)

5
scripts/manpages.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
set -e
rm -rf manpages
mkdir manpages
go run ./cmd/nfpm/ man | gzip -c >manpages/nfpm.1.gz