forked from clearlinux/swupd-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
swupd.bash
71 lines (65 loc) · 2.82 KB
/
swupd.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# Software Updater - autocompletion script
#
# Copyright © 2016 Intel Corporation.
#
# 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, version 2 or later of the License.
#
# 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, see <http://www.gnu.org/licenses/>.
#
# WARNING: This is an autogenerated script
#declares the completion function
_swupd()
{
local cur prev opts index suboptions mainsubcommands
local mainopts=" -h --help -v --version"
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
#Adding all options for subcommands in an array
mainsubcommands+=("bundle-add bundle-remove hashdump update verify check-update search")
suboptions+=("$mainopts")
suboptions+=(" -h --help -u --url -c --contenturl -v --versionurl -P --port -p --path -F --format -l --list -x --force -S --statedir")
mainsubcommands+=(" ")
suboptions+=(" -h --help -p --path -u --url -c --contenturl -v --versionurl -P --port -F --format -x --force -S --statedir")
mainsubcommands+=(" ")
suboptions+=(" -h --help -n --no-xattrs -b --basepath")
mainsubcommands+=(" ")
suboptions+=(" -h --help -d --download -u --url -P --port -c --contenturl -v --versionurl -s --status -F --format -p --path -x --force -S --statedir")
mainsubcommands+=(" ")
suboptions+=(" -h --help -m --manifest -p --path -u --url -P --port -c --contenturl -v --versionurl -f --fix -i --install -F --format -q --quick -x --force -S --statedir")
mainsubcommands+=(" ")
suboptions+=(" -h --help -u --url -v --versionurl -P --port -F --format -x --force -p --path -S --statedir")
mainsubcommands+=(" ")
suboptions+=(" -h --help -l --library -b --binary -s --scope -d --display-files -i --init -u --url -c --contenturl -v --versionurl -P --port -p --path -F --format -S --statedir")
mainsubcommands+=(" ")
#Need to get last subcommand entered by the user
index=COMP_CWORD-1
while [[ " swupd $mainsubcommands " != *" $prev "* ]]; do
((index--))
prev="${COMP_WORDS[$index]}"
done
#Now need to calculate the index of the subcommand in order to
#retreive options
index=0
for subc in swupd ${mainsubcommands[0]}
do
if [[ $subc == $prev ]]; then
break
fi
((index++))
done
#Get all options for last subcommand entered
opts="${suboptions[$index]} ${mainsubcommands[$index]}"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
}
complete -F _swupd swupd