summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2014-06-13 17:35:55 +0100
committerRichard Hughes <richard@hughsie.com>2014-06-13 17:35:55 +0100
commit95d01c0552322ec38fb3dfd4485443dafc29e385 (patch)
tree3b9f2a512f9b670d40f31c6906b2488cfff5dc56
parent03ddf073282de891ae4ab8a11ef0a306954b4709 (diff)
parentf7236af615acddadb6aa6d2d602259081d5188f1 (diff)
downloadappstream-glib-95d01c0552322ec38fb3dfd4485443dafc29e385.tar.gz
Merge pull request #3 from ignatenkobrain/master
improve bash-completion
-rw-r--r--configure.ac22
-rw-r--r--data/Makefile.am3
-rw-r--r--data/appstream-util72
3 files changed, 97 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 4855354..d0a0dc9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -95,6 +95,18 @@ AX_CHECK_COMPILE_FLAG([-fPIE],
AC_SUBST(PIE_CFLAGS)
AC_SUBST(PIE_LDFLAGS)
+# bash-completion
+AC_ARG_WITH([bashcompletiondir],
+ AS_HELP_STRING([--with-bashcompletiondir=DIR], [Bash completions directory]),
+ [],
+ [AS_IF([$($PKG_CONFIG --exists bash-completion)], [
+ with_bashcompletiondir=$($PKG_CONFIG --variable=completionsdir bash-completion)
+ ] , [
+ with_bashcompletiondir=${datadir}/bash-completion/completions
+ ])])
+AC_SUBST([bashcompletiondir], [$with_bashcompletiondir])
+
+
# use gperf for faster string -> enum matching
AC_PATH_PROG(GPERF, [gperf], [no])
if test x$GPERF != xno ; then
@@ -120,3 +132,13 @@ docs/api/Makefile
docs/api/version.xml
])
AC_OUTPUT
+AC_MSG_RESULT([
+ $PACKAGE_NAME $VERSION
+
+ prefix: ${prefix}
+ sysconf dir: ${sysconfdir}
+ datarootdir: ${datarootdir}
+ includedir: ${includedir}
+ lib dir: ${libdir}
+ Bash completion dir: ${with_bashcompletiondir}
+ ])
diff --git a/data/Makefile.am b/data/Makefile.am
index 26aca65..9d995c6 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,4 +1,7 @@
SUBDIRS = \
tests
+bashcompletiondir=@bashcompletiondir@
+dist_bashcompletion_DATA = appstream-util
+
-include $(top_srcdir)/git.mk
diff --git a/data/appstream-util b/data/appstream-util
new file mode 100644
index 0000000..2b379d5
--- /dev/null
+++ b/data/appstream-util
@@ -0,0 +1,72 @@
+# appstream-util completion -*- shell-script -*-
+#
+# This file is part of libappstream-glib.
+#
+# Copyright 2014 Igor Gnatenko
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License,
+# or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+_appstream-util()
+{
+ local cur prev words cword
+ _init_completion -s || return
+
+ local commandix command
+ for (( commandix=1; commandix < cword; commandix++ )); do
+ if [[ ${words[commandix]} != -* ]]; then
+ command=${words[commandix]}
+ break
+ fi
+ done
+
+ case $prev in
+ -h|--help|--version)
+ return
+ ;;
+ *)
+ ;;
+ esac
+
+ $split && return
+
+ if [[ $command ]]; then
+
+ case $command in
+ validate|validate-relax|validate-strict)
+ ext='@(appdata|metainfo).xml?(.in)'
+ ;;
+ install|uninstall)
+ ext='@(appdata|metainfo).xml'
+ ;;
+ dump)
+ ext='@(desktop|@(appdata|metainfo).xml)'
+ ;;
+ *)
+ ;;
+ esac
+ [[ -n $ext ]] && _filedir $ext
+ return
+ fi
+
+ if [[ $cur == -* ]]; then
+ COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ [[ $COMPREPLY == *= ]] && compopt -o nospace
+ elif [[ ! $command ]]; then
+ COMPREPLY=( $( compgen -W '$( "$1" list-commands 2>/dev/null )' -- "$cur" ) )
+ fi
+} &&
+complete -F _appstream-util appstream-util
+
+# ex: ts=4 sw=4 et filetype=sh