Merge pull request #3706 from mrueg/enable-autocmpl

ctr: Enable shell autocompletion
This commit is contained in:
Phil Estes 2019-10-03 09:15:51 -04:00 committed by GitHub
commit 309c9c25ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 1 deletions

View File

@ -294,7 +294,7 @@ root-coverage: ## generate coverage profiles for unit tests that require root
vendor: vendor:
@echo "$(WHALE) $@" @echo "$(WHALE) $@"
@vndr @vndr -whitelist github.com/urfave/cli/autocomplete/
help: ## this help help: ## this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort

View File

@ -71,6 +71,7 @@ stable from release to release of the containerd project.`
containerd CLI containerd CLI
` `
app.EnableBashCompletion = true
app.Flags = []cli.Flag{ app.Flags = []cli.Flag{
cli.BoolFlag{ cli.BoolFlag{
Name: "debug", Name: "debug",

21
vendor/github.com/urfave/cli/autocomplete/bash_autocomplete generated vendored Executable file
View File

@ -0,0 +1,21 @@
#! /bin/bash
: ${PROG:=$(basename ${BASH_SOURCE})}
_cli_bash_autocomplete() {
if [[ "${COMP_WORDS[0]}" != "source" ]]; then
local cur opts base
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
if [[ "$cur" == "-"* ]]; then
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion )
else
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
fi
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
}
complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete $PROG
unset PROG

View File

@ -0,0 +1,11 @@
_cli_zsh_autocomplete() {
local -a opts
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
_describe 'values' opts
return
}
compdef _cli_zsh_autocomplete $PROG