mirror of
https://github.com/containers/skopeo.git
synced 2025-07-13 06:24:39 +00:00
add support for completions
Signed-off-by: Mike Brown <brownwm@us.ibm.com>
This commit is contained in:
parent
e0d44861af
commit
a40d7b53aa
12
Makefile
12
Makefile
@ -1,12 +1,11 @@
|
|||||||
.PHONY: all binary build-container build-local clean install install-binary shell test-integration
|
.PHONY: all binary build-container build-local clean install install-binary install-completions shell test-integration
|
||||||
|
|
||||||
export GO15VENDOREXPERIMENT=1
|
export GO15VENDOREXPERIMENT=1
|
||||||
|
|
||||||
PREFIX ?= ${DESTDIR}/usr
|
PREFIX ?= ${DESTDIR}/usr
|
||||||
INSTALLDIR=${PREFIX}/bin
|
INSTALLDIR=${PREFIX}/bin
|
||||||
MANINSTALLDIR=${PREFIX}/share/man
|
MANINSTALLDIR=${PREFIX}/share/man
|
||||||
# TODO(runcom)
|
BASHINSTALLDIR=${PREFIX}/share/bash-completion/completions
|
||||||
#BASHINSTALLDIR=${PREFIX}/share/bash-completion/completions
|
|
||||||
GO_MD2MAN ?= /usr/bin/go-md2man
|
GO_MD2MAN ?= /usr/bin/go-md2man
|
||||||
|
|
||||||
ifeq ($(DEBUG), 1)
|
ifeq ($(DEBUG), 1)
|
||||||
@ -60,9 +59,7 @@ docs: $(MANPAGES_MD:%.md=%)
|
|||||||
clean:
|
clean:
|
||||||
rm -f skopeo docs/*.1
|
rm -f skopeo docs/*.1
|
||||||
|
|
||||||
install: install-binary install-docs
|
install: install-binary install-docs install-completions
|
||||||
# TODO(runcom)
|
|
||||||
#install -m 644 completion/bash/skopeo ${BASHINSTALLDIR}/
|
|
||||||
|
|
||||||
install-binary: ./skopeo
|
install-binary: ./skopeo
|
||||||
install -d -m 0755 ${INSTALLDIR}
|
install -d -m 0755 ${INSTALLDIR}
|
||||||
@ -72,6 +69,9 @@ install-docs: docs/skopeo.1
|
|||||||
install -d -m 0755 ${MANINSTALLDIR}/man1
|
install -d -m 0755 ${MANINSTALLDIR}/man1
|
||||||
install -m 644 docs/skopeo.1 ${MANINSTALLDIR}/man1/
|
install -m 644 docs/skopeo.1 ${MANINSTALLDIR}/man1/
|
||||||
|
|
||||||
|
install-completions:
|
||||||
|
install -m 644 -T hack/make/bash_autocomplete ${BASHINSTALLDIR}/skopeo
|
||||||
|
|
||||||
shell: build-container
|
shell: build-container
|
||||||
$(DOCKER_RUN_DOCKER) bash
|
$(DOCKER_RUN_DOCKER) bash
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ var gitCommit = ""
|
|||||||
// createApp returns a cli.App to be run or tested.
|
// createApp returns a cli.App to be run or tested.
|
||||||
func createApp() *cli.App {
|
func createApp() *cli.App {
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
|
app.EnableBashCompletion = true
|
||||||
app.Name = "skopeo"
|
app.Name = "skopeo"
|
||||||
if gitCommit != "" {
|
if gitCommit != "" {
|
||||||
app.Version = fmt.Sprintf("%s commit: %s", version.Version, gitCommit)
|
app.Version = fmt.Sprintf("%s commit: %s", version.Version, gitCommit)
|
||||||
|
14
hack/make/bash_autocomplete
Normal file
14
hack/make/bash_autocomplete
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
: ${PROG:=$(basename ${BASH_SOURCE})}
|
||||||
|
|
||||||
|
_cli_bash_autocomplete() {
|
||||||
|
local cur opts base
|
||||||
|
COMPREPLY=()
|
||||||
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
|
||||||
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
complete -F _cli_bash_autocomplete $PROG
|
Loading…
Reference in New Issue
Block a user