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 --name --only_jobs --list --completion --test_connection --input_boards --publish $opts2)
41 opts2=$(echo --command --sat $opts2)
44 opts2=$(echo --jobs_config --name $opts2)
48 COMPREPLY=( $(compgen -W "${opts2}" -- ${cur}) )
53 if [[ $appli != $prev ]]
55 opts=$(for x in `$SAT_PATH/sat -s config $appli -nv APPLICATION.products`
58 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
62 _salomeTools_complete()
64 if [[ "${SAT_PATH}x" == "x" ]]
69 local cur opts args command
72 cur="${COMP_WORDS[COMP_CWORD]}"
74 # second argument => show available APPLICATION
77 command="${COMP_WORDS[1]}"
82 if [[ ${command%%-*} == "" ]]
84 command="${COMP_WORDS[2]}"
85 argc="$((( argc - 1)))"
89 # first argument => show available commands
92 opts="config log testcommand source patch prepare environ clean configure make makeinstall compile launcher run jobs job shell --help"
93 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
99 # get list of APPLICATIONS
104 # option depending on command
105 local prev="${COMP_WORDS[COMP_CWORD-1]}"
107 if [[ ${prev} == "--value" || ${prev} == "-v" ]]
109 if [[ ${argc} == 4 ]]
112 opts=$(for x in `$SAT_PATH/sat config ${COMP_WORDS[COMP_CWORD-2]} -s ${COMP_WORDS[COMP_CWORD]}`
114 COMPREPLY=( $(compgen -W "${opts}" -S "." -- ${cur}) )
116 # without application
117 opts=$(for x in `$SAT_PATH/sat config -s ${COMP_WORDS[COMP_CWORD]}`
119 COMPREPLY=( $(compgen -W "${opts}" -S "." -- ${cur}) )
125 # show list of products
126 if [[ ${prev} == "--product" || ${prev} == "-p" ]]
128 appli="${COMP_WORDS[2]}"
129 if [[ ${command} != "source" ]]
131 opts=$(for x in `$SAT_PATH/sat config $appli -nv APPLICATION.products`
134 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
139 # show argument for each command
142 opts="--value --list --copy --edit --no_label --info"
143 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
147 opts="--clean --last --terminal --last"
148 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
152 opts="--products --sources --build --install --all --sources_without_dev"
153 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
158 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
163 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
167 opts="--products --force --force_patch"
168 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
172 opts="--products --shell --prefix --target"
173 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
177 opts="--products --option"
178 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
182 opts="--products --option"
183 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
188 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
192 opts="--products --with_fathers --with_children --clean_all --make_flags --show --stop_first_fail"
193 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
197 opts="--name --catalog --gencat"
198 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
202 opts="--name --only_jobs --list --completion --test_connection --input_boards --publish"
203 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
208 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
212 opts="--jobs_config --name"
213 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
221 # activation of auto-completion for the sat command
222 complete -F _salomeTools_complete sat
223 complete -F _salomeTools_complete ./sat