summaryrefslogtreecommitdiff
path: root/data/appstream-util
diff options
context:
space:
mode:
authorIgor Gnatenko <i.gnatenko.brain@gmail.com>2014-06-13 20:33:13 +0400
committerIgor Gnatenko <i.gnatenko.brain@gmail.com>2014-06-13 20:34:04 +0400
commitf7236af615acddadb6aa6d2d602259081d5188f1 (patch)
treef52add72bd325ac328900d20358fea3fb13089eb /data/appstream-util
parentf32a4e4c10e9f6b6bfb2a6a671d6d1802d4efe41 (diff)
downloadappstream-glib-f7236af615acddadb6aa6d2d602259081d5188f1.tar.gz
improve bash-completion
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Diffstat (limited to 'data/appstream-util')
-rw-r--r--data/appstream-util72
1 files changed, 72 insertions, 0 deletions
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