Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 1 .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/bin
/share/man/man1
/gh-cli
.envrc
/dist
Expand Down
13 changes: 12 additions & 1 deletion 13 .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ release:
before:
hooks:
- go mod tidy
- make manpages

builds:
- <<: &build_defaults
Expand All @@ -17,10 +18,12 @@ builds:
id: macos
goos: [darwin]
goarch: [amd64]

- <<: *build_defaults
id: linux
goos: [linux]
goarch: [386, amd64, arm64]

- <<: *build_defaults
id: windows
goos: [windows]
Expand All @@ -35,11 +38,16 @@ archives:
replacements:
darwin: macOS
format: tar.gz
files:
- LICENSE
- ./share/man/man1/gh*.1
- id: windows
builds: [windows]
<<: *archive_defaults
wrap_in_directory: false
format: zip
files:
- LICENSE

brews:
- name: gh
Expand All @@ -57,8 +65,9 @@ brews:
depends_on "go"
end
install: |
system "make" if build.head?
system "make", "bin/gh", "manpages" if build.head?
bin.install "bin/gh"
man1.install Dir["./share/man/man1/gh*.1"]
(bash_completion/"gh.sh").write `#{bin}/gh completion -s bash`
(zsh_completion/"_gh").write `#{bin}/gh completion -s zsh`
(fish_completion/"gh.fish").write `#{bin}/gh completion -s fish`
Expand All @@ -76,6 +85,8 @@ nfpms:
formats:
- deb
- rpm
files:
"./share/man/man1/gh*.1": "/usr/share/man/man1"

scoop:
bucket:
Expand Down
7 changes: 6 additions & 1 deletion 7 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ site:
site-docs: site
git -C site pull
git -C site rm 'manual/gh*.md' 2>/dev/null || true
go run ./cmd/gen-docs site/manual
go run ./cmd/gen-docs --website --doc-path site/manual
for f in site/manual/gh*.md; do sed -i.bak -e '/^### SEE ALSO/,$$d' "$$f"; done
rm -f site/manual/*.bak
git -C site add 'manual/gh*.md'
Expand All @@ -44,3 +44,8 @@ endif
git -C site commit -m '$(GITHUB_REF:refs/tags/v%=%)' index.html
git -C site push
.PHONY: site-publish


.PHONY: manpages
manpages:
go run ./cmd/gen-docs --man-page --doc-path ./share/man/man1/
51 changes: 44 additions & 7 deletions 51 cmd/gen-docs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,60 @@ import (

"github.com/cli/cli/command"
"github.com/spf13/cobra/doc"
"github.com/spf13/pflag"
)

func main() {
if len(os.Args) < 2 {
fatal("Usage: gen-docs <destination-dir>")

var flagError pflag.ErrorHandling
docCmd := pflag.NewFlagSet("", flagError)
manPage := docCmd.BoolP("man-page", "", false, "Generate manual pages")
website := docCmd.BoolP("website", "", false, "Generate website pages")
dir := docCmd.StringP("doc-path", "", "", "Path directory where you want generate doc files")
help := docCmd.BoolP("help", "h", false, "Help about any command")

if err := docCmd.Parse(os.Args); err != nil {
os.Exit(1)
}
dir := os.Args[1]

err := os.MkdirAll(dir, 0755)
if err != nil {
fatal(err)
if *help {
_, err := fmt.Fprintf(os.Stderr, "Usage of %s:\n\n%s", os.Args[0], docCmd.FlagUsages())
if err != nil {
fatal(err)
}
os.Exit(1)
}

if(*dir == "") {
fatal("no dir set")
}

err = doc.GenMarkdownTreeCustom(command.RootCmd, dir, filePrepender, linkHandler)

err := os.MkdirAll(*dir, 0755)
if err != nil {
fatal(err)
}

if *website {
err = doc.GenMarkdownTreeCustom(command.RootCmd, *dir, filePrepender, linkHandler)
if err != nil {
fatal(err)
}
}


if *manPage {
header := &doc.GenManHeader{
Title: "gh",
Section: "1",
Source: "", //source and manual are just put at the top of the manpage, before name
Manual: "", //if source is an empty string, it's set to "Auto generated by spf13/cobra"
}
err = doc.GenManTree(command.RootCmd, header, *dir)
if err != nil {
fatal(err)
}
}
}

func filePrepender(filename string) string {
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.