Skip to content

Commit 39c5352

Browse files
committed
init
1 parent cb43353 commit 39c5352

File tree

19 files changed

+754
-0
lines changed

19 files changed

+754
-0
lines changed

.github/workflows/release.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: goreleaser
2+
3+
on:
4+
push:
5+
# run only against tags
6+
tags:
7+
- '*'
8+
9+
permissions:
10+
contents: write
11+
# packages: write
12+
# issues: write
13+
14+
jobs:
15+
goreleaser:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
21+
- run: git fetch --force --tags
22+
- uses: actions/setup-go@v4
23+
with:
24+
go-version: stable
25+
# More assembly might be required: Docker logins, GPG, etc. It all depends
26+
# on your needs.
27+
- name: Run test
28+
run: make test
29+
- uses: goreleaser/goreleaser-action@v4
30+
with:
31+
# either 'goreleaser' (default) or 'goreleaser-pro':
32+
distribution: goreleaser
33+
version: latest
34+
args: release --clean
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro'
38+
# distribution:
39+
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/

.goreleaser.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# This is an example .goreleaser.yml file with some sensible defaults.
2+
# Make sure to check the documentation at https://goreleaser.com
3+
before:
4+
hooks:
5+
# You may remove this if you don't use go modules.
6+
- go mod tidy
7+
builds:
8+
- env:
9+
- CGO_ENABLED=0
10+
goos:
11+
- linux
12+
- darwin
13+
ldflags:
14+
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser
15+
flags:
16+
- -trimpath
17+
18+
archives:
19+
- format: tar.gz
20+
# this name template makes the OS and Arch compatible with the results of uname.
21+
name_template: >-
22+
{{ .ProjectName }}_
23+
{{- title .Os }}_
24+
{{- if eq .Arch "amd64" }}x86_64
25+
{{- else if eq .Arch "386" }}i386
26+
{{- else }}{{ .Arch }}{{ end }}
27+
{{- if .Arm }}v{{ .Arm }}{{ end }}
28+
checksum:
29+
name_template: 'checksums.txt'
30+
snapshot:
31+
name_template: "{{ incpatch .Version }}-next"
32+
changelog:
33+
sort: asc
34+
filters:
35+
exclude:
36+
- '^docs:'
37+
- '^test:'
38+
39+
# The lines beneath this are called `modelines`. See `:help modeline`
40+
# Feel free to remove those if you don't want/use them.
41+
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
42+
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
test:
2+
go test -v -cover ./...

README.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# zsh-manpage-completion-generator
2+
3+
Automatically generate zsh completions from man page using fish shell completion files.
4+
This program is inspired from [nevesnunes/sh-manpage-completions](https://github.com/nevesnunes/sh-manpage-completions).
5+
But it supports more completion files and is much simply implemented, faster and easier to use, written in Go.
6+
7+
## Requirements
8+
9+
This program depends on fish shell's manpage converter, [create_manpage_completions.py](https://github.com/fish-shell/fish-shell/blob/master/share/tools/create_manpage_completions.py).
10+
So you must first install fish shell, See below for installation instructions.
11+
12+
https://github.com/fish-shell/fish-shell
13+
14+
If you do not want to install fish, you can also manually place and run the conversion python script.
15+
16+
## Installation
17+
18+
**Normal:**
19+
20+
Download the binary from [GitHub Releases][release] and drop it in your `$PATH`.
21+
22+
- [Linux][release]
23+
- [Mac][release]
24+
25+
**Go install:**
26+
27+
```bash
28+
go install github.com/umlx5h/zsh-manpage-completion-generator@latest
29+
```
30+
31+
## Usage
32+
33+
You must first generate fish competion files.
34+
It generates completion files, usually under folder `$XDG_DATA_HOME/.local/share/fish/generated_completions`
35+
36+
```console
37+
$ fish -c 'fish_update_completions'
38+
Parsing man pages and writing completions to /home/dummy/.local/share/fish/generated_completions/
39+
```
40+
41+
Then generate zsh completions from fish completions folder.
42+
By default, it is generated in folder `$XDG_DATA_HOME/.local/share/zsh/generated_man_completions`
43+
44+
```console
45+
$ zsh-manpage-completion-generator
46+
Converting fish completions: /home/dummy/.local/share/fish/generated_completions -> /home/dummy/.local/share/zsh/generated_man_completions
47+
Completed. converted: 2579/2581, skipped: 142
48+
```
49+
50+
Then add completions folder to your `fpath` in `.zshrc`.
51+
(It is recommended to place them at the end of the `fpath`, so that human-generated completions such as [zsh-users/zsh-completions](https://github.com/zsh-users/zsh-completions) will be preferred.)
52+
53+
```
54+
fpath=(
55+
$fpath
56+
$HOME/.local/share/zsh/generated_man_completions
57+
)
58+
compinit # This is not necessary if it is called after this.
59+
```
60+
61+
You may have to force rebuild zcompdump
62+
```console
63+
$ rm -f ~/.zcompdump && compinit
64+
```
65+
66+
It is recommended that `compinit` be called only once because of the startup time.
67+
You can check the number of calls to `compinit` by using `zprof`.
68+
69+
Note that `fpath` must be added before `compinit`.
70+
If you are using any zsh framework, check where it is adding `fpath` and calling `compinit`.
71+
72+
## Option
73+
74+
The following command line options are supported.
75+
76+
You can change the path to the fish and zsh completions by specifying `-dst` and `-src`.
77+
The `-clean` option can be specified to remove zsh completion folder before generating them.
78+
This is useful for removing completions that are no longer needed.
79+
(Note that the entire `-dst` folder will be deleted.)
80+
81+
```console
82+
$ zsh-manpage-completion-generator -h
83+
Usage of zsh-manpage-completion-generator:
84+
-clean
85+
CAUTION: remove destination folder before converting
86+
-dst string
87+
zsh generated_completions destination folder (default "/home/dummy/.local/share/zsh/generated_man_completions")
88+
-src string
89+
fish generated_completions src folder (default "/home/dummy/.local/share/fish/generated_completions")
90+
-verbose
91+
verbose log
92+
-version
93+
show version
94+
```
95+
96+
## Caveat
97+
98+
- Some invalid options may be generated, but there is nothing that can be done about this, as this is also the case with fish.
99+
100+
## Related
101+
102+
- [nevesnunes/sh-manpage-completions](https://github.com/nevesnunes/sh-manpage-completions)
103+
- [RobSis/zsh-completion-generator](https://github.com/RobSis/zsh-completion-generator)
104+
105+
## License
106+
107+
MIT
108+
109+
[release]: https://github.com/umlx5h/zsh-manpage-completion-generator/releases/latest

go.mod

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module github.com/umlx5h/zsh-manpage-completion-generator
2+
3+
go 1.20
4+
5+
require (
6+
github.com/google/go-cmp v0.5.9
7+
github.com/stretchr/testify v1.8.4
8+
)
9+
10+
require (
11+
github.com/davecgh/go-spew v1.1.1 // indirect
12+
github.com/pmezard/go-difflib v1.0.0 // indirect
13+
gopkg.in/yaml.v3 v3.0.1 // indirect
14+
)

go.sum

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
4+
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
5+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
6+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
7+
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
8+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
9+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
10+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
11+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
12+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)