burrow command completion working

This commit is contained in:
James Tomasino 2018-01-20 15:20:25 -05:00
parent 5b835cab8c
commit be30f4ab06
3 changed files with 17 additions and 13 deletions

View File

@ -1,7 +1,7 @@
PREFIX ?= /usr
BINDIR ?= $(PREFIX)/bin
MANDIR ?= $(PREFIX)/share/man
CPLDIR ?= /etc/bash_completion.d
CPLDIR ?= $$(pkg-config --variable=completionsdir bash-completion)
install:
@echo Installing the executable to $(DESTDIR)$(BINDIR)
@ -13,8 +13,8 @@ install:
@cp -f burrow.1 $(DESTDIR)$(MANDIR)/man1/burrow.1
@chmod 644 $(DESTDIR)$(MANDIR)/man1/burrow.1
@echo Installing the command completion to $(DESTDIR)$(CPLDIR)
@cp -f burrow.d $(DESTDIR)$(CPLDIR)/burrow.d
@chmod 644 $(DESTDIR)$(CPLDIR)/burrow.d
@cp -f burrow.d $(DESTDIR)$(CPLDIR)/burrow
@chmod 644 $(DESTDIR)$(CPLDIR)/burrow
uninstall:
@echo Removing the executable from $(DESTDIR)$(BINDIR)
@ -22,6 +22,6 @@ uninstall:
@echo Removing the manual page from $(DESTDIR)$(MANDIR)/man1
@rm -f $(DESTDIR)$(BINDIR)/man1/burrow.1
@echo Removing the command completion from $(DESTDIR)$(CPLDIR)
@rm -f $(DESTDIR)$(CPLDIR)/burrow.d
@rm -f $(DESTDIR)$(CPLDIR)/burrow
.PHONY: install uninstall

4
burrow
View File

@ -75,6 +75,10 @@ function parseargs() {
show_help
exit 0
;;
"SHORTLIST")
echo "phlog recipe create-config update-git"
exit 0
;;
"PHLOG") arg_phlog=1 ;;
"RECIPE") arg_recipe=1 ;;
"CREATE-CONFIG") arg_create_config=1 ;;

View File

@ -1,14 +1,14 @@
#!/usr/bin/env bash
_burrow()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="phlog recipe create-config update-git -v -h"
# Get basic autocomplete commands from the function itself
local helplist
helplist=$(burrow shortlist)
if [[ ${cur} == -* ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
# Combine all the lists for autocomplete
local cur
cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $( compgen -W "$helplist" -- "$cur" ) )
}
complete -F _burrow burrow