From b5fa55b0c2837d033614c2c2ab1488d097aec2a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Tue, 1 Oct 2019 09:29:02 +0200 Subject: [PATCH] ctr: Enable shell autocompletion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel RĂ¼ger --- Makefile | 2 +- cmd/ctr/app/main.go | 1 + .../urfave/cli/autocomplete/bash_autocomplete | 21 +++++++++++++++++++ .../urfave/cli/autocomplete/zsh_autocomplete | 11 ++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100755 vendor/github.com/urfave/cli/autocomplete/bash_autocomplete create mode 100644 vendor/github.com/urfave/cli/autocomplete/zsh_autocomplete diff --git a/Makefile b/Makefile index 675816189..f79208c53 100644 --- a/Makefile +++ b/Makefile @@ -294,7 +294,7 @@ root-coverage: ## generate coverage profiles for unit tests that require root vendor: @echo "$(WHALE) $@" - @vndr + @vndr -whitelist github.com/urfave/cli/autocomplete/ help: ## this help @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort diff --git a/cmd/ctr/app/main.go b/cmd/ctr/app/main.go index d0b277cf2..7c5127fc6 100644 --- a/cmd/ctr/app/main.go +++ b/cmd/ctr/app/main.go @@ -71,6 +71,7 @@ stable from release to release of the containerd project.` containerd CLI ` + app.EnableBashCompletion = true app.Flags = []cli.Flag{ cli.BoolFlag{ Name: "debug", diff --git a/vendor/github.com/urfave/cli/autocomplete/bash_autocomplete b/vendor/github.com/urfave/cli/autocomplete/bash_autocomplete new file mode 100755 index 000000000..f0f624183 --- /dev/null +++ b/vendor/github.com/urfave/cli/autocomplete/bash_autocomplete @@ -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 diff --git a/vendor/github.com/urfave/cli/autocomplete/zsh_autocomplete b/vendor/github.com/urfave/cli/autocomplete/zsh_autocomplete new file mode 100644 index 000000000..8b747ae0d --- /dev/null +++ b/vendor/github.com/urfave/cli/autocomplete/zsh_autocomplete @@ -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