X Tutup
Skip to content

Commit 3bf461a

Browse files
committed
Move autocomplete files to contrib/
Since recent versions of `vndr` are going to remove the autocomplete scripts from the urfave vendored content, we will just move them into `contrib/` and reference them in the documentation from that location. Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
1 parent 3e3c5fe commit 3bf461a

File tree

3 files changed

+46
-9
lines changed

3 files changed

+46
-9
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -220,23 +220,23 @@ architectures, such as [Canonical's Ubuntu packaging](https://launchpad.net/ubun
220220

221221
#### Enabling command auto-completion
222222

223-
Starting with containerd 1.4, the urfave client feature for auto-creation of bash
224-
autocompletion data is enabled. To use the autocomplete feature in your shell, source
225-
the autocomplete/bash_autocomplete file in your .bashrc file while setting the `PROG`
226-
variable to `ctr`:
223+
Starting with containerd 1.4, the urfave client feature for auto-creation of bash and zsh
224+
autocompletion data is enabled. To use the autocomplete feature in a bash shell for example, source
225+
the autocomplete/ctr file in your `.bashrc`, or manually like:
227226

228227
```
229-
$ PROG=ctr source vendor/github.com/urfave/cli/autocomplete/bash_autocomplete
228+
$ source ./contrib/autocomplete/ctr
230229
```
231230

232-
#### Distribution of `ctr` autocomplete for bash
231+
#### Distribution of `ctr` autocomplete for bash and zsh
233232

234-
Copy `vendor/github.com/urfave/cli/autocomplete/bash_autocomplete` into
235-
`/etc/bash_completion.d/` and rename it to `ctr`.
233+
For bash, copy the `contrib/autocomplete/ctr` script into
234+
`/etc/bash_completion.d/` and rename it to `ctr`. The `zsh_autocomplete`
235+
file is also available and can be used similarly for zsh users.
236236

237237
Provide documentation to users to `source` this file into their shell if
238238
you don't place the autocomplete file in a location where it is automatically
239-
loaded for user's bash shell environment.
239+
loaded for the user's shell environment.
240240

241241
### Communication
242242

contrib/autocomplete/ctr

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#! /bin/bash
2+
## This file is a direct copy of https://github.com/urfave/cli/blob/a221e662f14fd7404302444a5c4293409a401210/autocomplete/bash_autocomplete
3+
4+
: ${PROG:=$(basename ${BASH_SOURCE})}
5+
6+
_cli_bash_autocomplete() {
7+
if [[ "${COMP_WORDS[0]}" != "source" ]]; then
8+
local cur opts base
9+
COMPREPLY=()
10+
cur="${COMP_WORDS[COMP_CWORD]}"
11+
if [[ "$cur" == "-"* ]]; then
12+
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion )
13+
else
14+
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
15+
fi
16+
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
17+
return 0
18+
fi
19+
}
20+
21+
complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete $PROG
22+
unset PROG
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#compdef ctr
2+
# This file is a direct copy of https://github.com/urfave/cli/blob/a221e662f14fd7404302444a5c4293409a401210/autocomplete/zsh_autocomplete
3+
# With $PROG changed to ctr
4+
5+
_cli_zsh_autocomplete() {
6+
7+
local -a opts
8+
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
9+
10+
_describe 'values' opts
11+
12+
return
13+
}
14+
15+
compdef _cli_zsh_autocomplete ctr

0 commit comments

Comments
 (0)
X Tutup