Blame SOURCES/0007-Add-bash-completion-file.patch

f928ec
From a797a566127f7469d744b2748f98d1fa5ea8d8f9 Mon Sep 17 00:00:00 2001
89397c
From: Peter Jones <pjones@redhat.com>
89397c
Date: Tue, 14 Jun 2016 10:20:14 -0400
f928ec
Subject: [PATCH 07/10] Add bash completion file.
89397c
89397c
Signed-off-by: Peter Jones <pjones@redhat.com>
89397c
---
89397c
 configure.ac | 17 +++++++++++++++++
f928ec
 Makefile.am  |  5 +++++
89397c
 data/mokutil | 37 +++++++++++++++++++++++++++++++++++++
89397c
 3 files changed, 59 insertions(+)
89397c
 create mode 100755 data/mokutil
89397c
89397c
diff --git a/configure.ac b/configure.ac
f928ec
index 69d412ac633..7b52a063df0 100644
89397c
--- a/configure.ac
89397c
+++ b/configure.ac
89397c
@@ -86,6 +86,23 @@ AC_CHECK_FUNCS([memset])
89397c
 PKG_CHECK_MODULES(OPENSSL, [openssl >= 0.9.8])
89397c
 PKG_CHECK_MODULES(EFIVAR, [efivar >= 0.12])
89397c
 
89397c
+AC_ARG_WITH([bash-completion-dir],
89397c
+    AS_HELP_STRING([--with-bash-completion-dir[=PATH]],
89397c
+        [Install the bash auto-completion script in this directory. @<:@default=yes@:>@]),
89397c
+    [],
89397c
+    [with_bash_completion_dir=yes])
89397c
+
89397c
+if test "x$with_bash_completion_dir" = "xyes"; then
89397c
+    PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0],
89397c
+        [BASH_COMPLETION_DIR="`pkg-config --variable=completionsdir bash-completion`"],
89397c
+        [BASH_COMPLETION_DIR="$datadir/bash-completion/completions"])
89397c
+else
89397c
+    BASH_COMPLETION_DIR="$with_bash_completion_dir"
89397c
+fi
89397c
+
89397c
+AC_SUBST([BASH_COMPLETION_DIR])
89397c
+AM_CONDITIONAL([ENABLE_BASH_COMPLETION],[test "x$with_bash_completion_dir" != "xno"])
89397c
+
89397c
 AC_CONFIG_FILES([Makefile
89397c
                  src/Makefile
89397c
 		 man/Makefile])
f928ec
diff --git a/Makefile.am b/Makefile.am
f928ec
index 9f0d4192515..c17cc4a86d8 100644
f928ec
--- a/Makefile.am
f928ec
+++ b/Makefile.am
f928ec
@@ -1 +1,6 @@
f928ec
 SUBDIRS = src man
f928ec
+
f928ec
+if ENABLE_BASH_COMPLETION
f928ec
+  bashcompletiondir = $(BASH_COMPLETION_DIR)
f928ec
+  dist_bashcompletion_DATA = data/mokutil
f928ec
+endif
89397c
diff --git a/data/mokutil b/data/mokutil
89397c
new file mode 100755
f928ec
index 00000000000..800b039e7f4
89397c
--- /dev/null
89397c
+++ b/data/mokutil
89397c
@@ -0,0 +1,37 @@
89397c
+#!/bin/bash
89397c
+
89397c
+_mokutil()
89397c
+{
89397c
+	local cur=${COMP_WORDS[COMP_CWORD]}
89397c
+
89397c
+	if [[ "$cur" == -* ]]; then
89397c
+		#COMPREPLY=( $( compgen -W "--help --list-enrolled --list-new --list-delete --import --delete --revoke-import --revoke-delete --export --password --clear-password --disable-validation --enable-validation --sb-state --test-key --reset --generate-hash --hash-file --root-pw --simple-hash" -- $cur ) )
89397c
+		COMPREPLY=( $( compgen -W '$( _parse_help "$1" --long-help ) -h -l -N -D -i -d -x -p -c -t -f -g -P -s -X' -- "$cur" ) )
89397c
+		[[ $COMPREPLY == *= ]] && compopt -o nospace
89397c
+		return 0
89397c
+	fi
89397c
+
89397c
+	case "${COMP_WORDS[COMP_CWORD-1]}" in
89397c
+	--import|-i|--delete|-d|--test-key|-t|--hash-file|-f)
89397c
+		_filedir
89397c
+		return 0
89397c
+		;;
89397c
+	--import-hash|--delete-hash)
89397c
+		COMPREPLY=( $( compgen -W "" ) )
89397c
+		return 0
89397c
+		;;
89397c
+	--set-verbosity)
89397c
+		COMPREPLY=( $( compgen -W "true false") )
89397c
+		return 0
89397c
+		;;
89397c
+	--generate-hash|-g)
89397c
+		COMPREPLY=( $( compgen -o nospace -P= -W "") )
89397c
+		return 0
89397c
+		;;
89397c
+	*)
89397c
+		return 0
89397c
+		;;
89397c
+	esac
89397c
+}
89397c
+
89397c
+complete -F _mokutil mokutil
89397c
-- 
f928ec
2.17.1
89397c