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)
47 opts2=$(echo --base --display --grid --launcher --session $opts2)
50 opts2=$(echo --name --project --salometools $opts2)
53 opts2=$(echo --path --exclude-file --exclude-extension --exclude-path $opts2)
56 opts2=$(echo --name --template --target --param --info $opts2)
60 COMPREPLY=( $(compgen -W "${opts2}" -- ${cur}) )
65 if [[ $appli != $prev ]]
67 opts=$(for x in `$SAT_PATH/sat -s config $appli -nv APPLICATION.products`
70 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
74 _salomeTools_complete()
76 if [[ "${SAT_PATH}x" == "x" ]]
81 local cur opts args command
84 cur="${COMP_WORDS[COMP_CWORD]}"
86 # second argument => show available APPLICATION
89 command="${COMP_WORDS[1]}"
94 if [[ ${command%%-*} == "" ]]
96 command="${COMP_WORDS[2]}"
97 argc="$((( argc - 1)))"
101 # first argument => show available commands
102 if [[ ${argc} == 1 ]]
104 opts="config log testcommand source patch prepare environ clean configure make makeinstall compile launcher run jobs job shell test package generate find_duplicates application template --help"
105 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
109 if [[ ${argc} == 2 ]]
111 # get list of APPLICATIONS
116 # option depending on command
117 local prev="${COMP_WORDS[COMP_CWORD-1]}"
119 if [[ ${prev} == "--value" || ${prev} == "-v" ]]
121 if [[ ${argc} == 4 ]]
124 opts=$(for x in `$SAT_PATH/sat config ${COMP_WORDS[COMP_CWORD-2]} -s ${COMP_WORDS[COMP_CWORD]}`
126 COMPREPLY=( $(compgen -W "${opts}" -S "." -- ${cur}) )
128 # without application
129 opts=$(for x in `$SAT_PATH/sat config -s ${COMP_WORDS[COMP_CWORD]}`
131 COMPREPLY=( $(compgen -W "${opts}" -S "." -- ${cur}) )
137 # show list of products
138 if [[ ${prev} == "--product" || ${prev} == "-p" ]]
140 appli="${COMP_WORDS[2]}"
141 if [[ ${command} != "source" ]]
143 opts=$(for x in `$SAT_PATH/sat config $appli -nv APPLICATION.products`
146 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
151 # show argument for each command
154 opts="--value --list --copy --edit --no_label --info"
155 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
159 opts="--clean --last --terminal --last"
160 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
164 opts="--products --sources --build --install --all --sources_without_dev"
165 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
170 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
175 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
179 opts="--products --force --force_patch"
180 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
184 opts="--products --shell --prefix --target"
185 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
189 opts="--products --option"
190 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
194 opts="--products --option"
195 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
200 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
204 opts="--products --with_fathers --with_children --clean_all --make_flags --show --stop_first_fail"
205 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
209 opts="--name --catalog --gencat"
210 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
214 opts="--name --only_jobs --list --completion --test_connection --input_boards --publish"
215 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
220 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
224 opts="--jobs_config --name"
225 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
229 opts="--base --launcher --grid --session --display"
230 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
234 opts="--name --binaries --sources --project --salometools --with_vcs"
235 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
239 opts="--products --yacsgen"
240 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
244 opts="--path --sources --exclude-file --exclude-extension --exclude-path"
245 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
249 opts="--name --catalog --target --gencat --module"
250 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
254 opts="--name --template --target --param --info"
255 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
263 # activation of auto-completion for the sat command
264 complete -F _salomeTools_complete sat
265 complete -F _salomeTools_complete ./sat