| 1 |
# |
| 2 |
# bash completion support for PackageKit's console commands. |
| 3 |
# |
| 4 |
# Copyright (C) 2007 James Bowes <[email protected]> |
| 5 |
# Copyright (C) 2010 Richard Hughes <[email protected]> |
| 6 |
# |
| 7 |
# Licensed under the GNU General Public License Version 2 |
| 8 |
# |
| 9 |
# This program is free software; you can redistribute it and/or modify |
| 10 |
# it under the terms of the GNU General Public License as published by |
| 11 |
# the Free Software Foundation; either version 2 of the License, or |
| 12 |
# (at your option) any later version. |
| 13 |
# |
| 14 |
# To use the completion: |
| 15 |
# 1. Copy this file somewhere (e.g. ~/.pk-completion.sh). |
| 16 |
# 2. Add the following line to your .bashrc: |
| 17 |
# source ~/.pk-completion.sh |
| 18 |
|
| 19 |
|
| 20 |
__pkcon_commandlist=" |
| 21 |
accept-eula |
| 22 |
backend-details |
| 23 |
get-roles |
| 24 |
depends-on |
| 25 |
get-details |
| 26 |
get-distro-upgrades |
| 27 |
get-files |
| 28 |
get-filters |
| 29 |
get-groups |
| 30 |
get-packages |
| 31 |
download |
| 32 |
required-by |
| 33 |
get-time |
| 34 |
get-transactions |
| 35 |
get-update-detail |
| 36 |
get-updates |
| 37 |
get-categories |
| 38 |
install |
| 39 |
install-local |
| 40 |
list-create |
| 41 |
offline-get-prepared |
| 42 |
offline-status |
| 43 |
offline-trigger |
| 44 |
refresh |
| 45 |
remove |
| 46 |
repo-disable |
| 47 |
repo-enable |
| 48 |
repo-list |
| 49 |
repo-set-data |
| 50 |
resolve |
| 51 |
search |
| 52 |
quit |
| 53 |
update |
| 54 |
upgrade-system |
| 55 |
repair |
| 56 |
" |
| 57 |
|
| 58 |
__pkconcomp () |
| 59 |
{ |
| 60 |
local all c s=$'\n' IFS=' '$'\t'$'\n' |
| 61 |
local cur="${COMP_WORDS[COMP_CWORD]}" |
| 62 |
if [ $# -gt 2 ]; then |
| 63 |
cur="$3" |
| 64 |
fi |
| 65 |
for c in $1; do |
| 66 |
case "$c$4" in |
| 67 |
*.) all="$all$c$4$s" ;; |
| 68 |
*) all="$all$c$4 $s" ;; |
| 69 |
esac |
| 70 |
done |
| 71 |
IFS=$s |
| 72 |
COMPREPLY=($(compgen -P "$2" -W "$all" -- "$cur")) |
| 73 |
return |
| 74 |
} |
| 75 |
|
| 76 |
_pkcon_search () |
| 77 |
{ |
| 78 |
local i c=1 command |
| 79 |
while [ $c -lt $COMP_CWORD ]; do |
| 80 |
i="${COMP_WORDS[c]}" |
| 81 |
case "$i" in |
| 82 |
name|details|group|file) |
| 83 |
command="$i" |
| 84 |
break |
| 85 |
;; |
| 86 |
esac |
| 87 |
c=$((++c)) |
| 88 |
done |
| 89 |
|
| 90 |
if [ $c -eq $COMP_CWORD -a -z "$command" ]; then |
| 91 |
__pkconcomp "name details group file" |
| 92 |
fi |
| 93 |
return |
| 94 |
} |
| 95 |
|
| 96 |
_pkcon () |
| 97 |
{ |
| 98 |
local i c=1 command |
| 99 |
|
| 100 |
while [ $c -lt $COMP_CWORD ]; do |
| 101 |
i="${COMP_WORDS[c]}" |
| 102 |
case "$i" in |
| 103 |
--version|--help|--verbose|--nowait|-v|-n|-h|-?) ;; |
| 104 |
*) command="$i"; break ;; |
| 105 |
esac |
| 106 |
c=$((++c)) |
| 107 |
done |
| 108 |
|
| 109 |
if [ $c -eq $COMP_CWORD -a -z "$command" ]; then |
| 110 |
case "${COMP_WORDS[COMP_CWORD]}" in |
| 111 |
--*=*) COMPREPLY=() ;; |
| 112 |
--*) __pkconcomp " |
| 113 |
--version |
| 114 |
--filter |
| 115 |
--verbose |
| 116 |
--help |
| 117 |
--nowait |
| 118 |
" |
| 119 |
;; |
| 120 |
-*) __pkconcomp " |
| 121 |
-v |
| 122 |
-n |
| 123 |
-h |
| 124 |
-? |
| 125 |
--version |
| 126 |
--verbose |
| 127 |
--help |
| 128 |
--filter |
| 129 |
--nowait |
| 130 |
" |
| 131 |
;; |
| 132 |
*) __pkconcomp "$__pkcon_commandlist" ;; |
| 133 |
esac |
| 134 |
return |
| 135 |
fi |
| 136 |
|
| 137 |
case "$command" in |
| 138 |
search) _pkcon_search ;; |
| 139 |
*) COMPREPLY=() ;; |
| 140 |
esac |
| 141 |
} |
| 142 |
|
| 143 |
complete -o default -o nospace -F _pkcon pkcon |