2 # Copyright (C) 2010-2012 CEA/DEN
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # Completion Function for salomeTools (sat)
20 export SAT_PATH=$(cd `dirname "${BASH_SOURCE}"` && pwd)
24 local opts2=$(for x in `$SAT_PATH/sat config -nl`
29 # additional options for command working without applications
32 opts2=$(echo --list --value --edit --info $opts2)
35 opts2=$(echo --clean --full --last --terminal $opts2)
38 opts2=$(echo --jobs_config --only_jobs --list --no_label --test_connection --publish $opts2)
41 opts2=$(echo --command --sat $opts2)
45 COMPREPLY=( $(compgen -W "${opts2}" -- ${cur}) )
50 if [[ $appli != $prev ]]
52 opts=$(for x in `$SAT_PATH/sat -s config $appli -nv APPLICATION.products`
55 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
59 _salomeTools_complete()
61 if [[ "${SAT_PATH}x" == "x" ]]
66 local cur opts args command
69 cur="${COMP_WORDS[COMP_CWORD]}"
71 # second argument => show available APPLICATION
74 command="${COMP_WORDS[1]}"
79 if [[ ${command%%-*} == "" ]]
81 command="${COMP_WORDS[2]}"
82 argc="$((( argc - 1)))"
86 # first argument => show available commands
89 opts="config log testcommand source patch prepare environ clean configure make makeinstall compile launcher run jobs shell --help"
90 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
96 # get list of APPLICATIONS
101 # option depending on command
102 local prev="${COMP_WORDS[COMP_CWORD-1]}"
104 if [[ ${prev} == "--value" || ${prev} == "-v" ]]
106 if [[ ${argc} == 4 ]]
109 opts=$(for x in `$SAT_PATH/sat config ${COMP_WORDS[COMP_CWORD-2]} -s ${COMP_WORDS[COMP_CWORD]}`
111 COMPREPLY=( $(compgen -W "${opts}" -S "." -- ${cur}) )
113 # without application
114 opts=$(for x in `$SAT_PATH/sat config -s ${COMP_WORDS[COMP_CWORD]}`
116 COMPREPLY=( $(compgen -W "${opts}" -S "." -- ${cur}) )
122 # show list of products
123 if [[ ${prev} == "--product" || ${prev} == "-p" ]]
125 appli="${COMP_WORDS[2]}"
126 if [[ ${command} != "source" ]]
128 opts=$(for x in `$SAT_PATH/sat config $appli -nv APPLICATION.products`
131 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
136 # show argument for each command
139 opts="--value --list --copy --edit --no_label --info"
140 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
144 opts="--clean --last --terminal --last"
145 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
149 opts="--products --sources --build --install --all --sources_without_dev"
150 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
155 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
160 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
164 opts="--products --force --force_patch"
165 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
169 opts="--products --shell --prefix --target"
170 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
174 opts="--products --option"
175 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
179 opts="--products --option"
180 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
185 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
189 opts="--products --with_fathers --with_children --clean_all --make_flags --show --stop_first_fail"
190 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
194 opts="--name --catalog --gencat"
195 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
199 opts="--jobs_config --only_jobs --list --no_label --test_connection --publish"
200 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
204 opts="--command --sat"
205 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
213 # activation of auto-completion for the sat command
214 complete -F _salomeTools_complete sat
215 complete -F _salomeTools_complete ./sat