Skip to content

Commit d65684c

Browse files
committed
Add Zsh completion
1 parent 6ecc626 commit d65684c

File tree

2 files changed

+13
-59
lines changed

2 files changed

+13
-59
lines changed

_pass-gen

+11-58
Original file line numberDiff line numberDiff line change
@@ -2,83 +2,36 @@
22

33
autoload -U is-at-least
44

5-
_gutenberg() {
5+
_pass-gen() {
66
typeset -A opt_args
77
typeset -a _arguments_options
88
local ret=1
99

1010
local context curcontext="$curcontext" state line
1111
_arguments "${_arguments_options[@]}" \
12-
'-c+[Path to a config file other than config.toml]' \
13-
'--config=[Path to a config file other than config.toml]' \
14-
'-h[Prints help information]' \
15-
'--help[Prints help information]' \
16-
'-V[Prints version information]' \
17-
'--version[Prints version information]' \
18-
":: :_gutenberg_commands" \
19-
"*::: :->gutenberg" \
12+
":: :_pass-gen_commands" \
13+
"*::: :->pass-gen" \
2014
&& ret=0
2115
case $state in
22-
(gutenberg)
16+
(pass-gen)
2317
words=($line[1] "${words[@]}")
2418
(( CURRENT += 1 ))
25-
curcontext="${curcontext%:*:*}:gutenberg-command-$line[1]:"
19+
curcontext="${curcontext%:*:*}:pass-gen-command-$line[1]:"
2620
case $line[1] in
2721
(init)
2822
_arguments "${_arguments_options[@]}" \
29-
'-h[Prints help information]' \
30-
'--help[Prints help information]' \
31-
'-V[Prints version information]' \
32-
'--version[Prints version information]' \
33-
':name -- Name of the project. Will create a new directory with that name in the current directory:_files' \
34-
&& ret=0
35-
;;
36-
(build)
37-
_arguments "${_arguments_options[@]}" \
38-
'-u+[Force the base URL to be that value (default to the one in config.toml)]' \
39-
'--base-url=[Force the base URL to be that value (default to the one in config.toml)]' \
40-
'-o+[Outputs the generated site in the given path]' \
41-
'--output-dir=[Outputs the generated site in the given path]' \
42-
'-h[Prints help information]' \
43-
'--help[Prints help information]' \
44-
'-V[Prints version information]' \
45-
'--version[Prints version information]' \
46-
&& ret=0
47-
;;
48-
(serve)
49-
_arguments "${_arguments_options[@]}" \
50-
'-i+[Interface to bind on]' \
51-
'--interface=[Interface to bind on]' \
52-
'-p+[Which port to use]' \
53-
'--port=[Which port to use]' \
54-
'-o+[Outputs the generated site in the given path]' \
55-
'--output-dir=[Outputs the generated site in the given path]' \
56-
'-u+[Changes the base_url]' \
57-
'--base-url=[Changes the base_url]' \
58-
'-h[Prints help information]' \
59-
'--help[Prints help information]' \
60-
'-V[Prints version information]' \
61-
'--version[Prints version information]' \
62-
&& ret=0
63-
;;
64-
(help)
65-
_arguments "${_arguments_options[@]}" \
66-
'-h[Prints help information]' \
67-
'--help[Prints help information]' \
68-
'-V[Prints version information]' \
69-
'--version[Prints version information]' \
23+
'' \
7024
&& ret=0
7125
;;
7226
esac
7327
;;
7428
esac
7529
}
7630

77-
(( $+functions[_gutenberg_commands] )) ||
78-
_gutenberg_commands() {
31+
(( $+functions[_pass-gen_commands] )) ||
32+
_pass-gen_commands() {
7933
local commands; commands=(
80-
"init:Create a new project" \
81-
"--length:use NUMBER words to generate the passphrase" \
34+
"--length:use NUMBER words to generate the passphrase" \
8235
"-l:use NUMBER words to generate the passphrase" \
8336
"--padding-before:preceed passphrase with NUMBER random numbers" \
8437
"--padding-after:follow passphrase with NUMBER random numbers" \
@@ -95,6 +48,6 @@ _gutenberg_commands() {
9548
"--help:display help message and exit" \
9649
"-h:display help message and exit"
9750
)
98-
_describe -t commands 'gutenberg commands' commands "$@"
51+
_describe -t commands 'pass-gen commands' commands "$@"
9952
}
100-
_gutenberg "$@"
53+
_pass-gen "$@"

makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ install :
33
install -m 0644 -v ./man/pass-gen.1 /usr/local/share/man/man1/pass-gen.1
44
install -m 0755 -v ./pass-gen /usr/local/bin/pass-gen
55
install -d /usr/local/lib/pass-gen
6-
install -d /usr/local/share/zsh/site-functions
6+
install -d /usr/share/zsh/site-functions
7+
install -m 0755 -v ./_pass-gen /usr/share/zsh/site-functions/_pass-gen
78
cp -r ./character-lists /usr/local/lib/pass-gen
89
cp -r ./wordlists /usr/local/lib/pass-gen
910

0 commit comments

Comments
 (0)