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 --no_browser $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)
59 opts2=$(echo --set $opts2)
62 opts2=$(echo --base --workdir --VCS --tag --log_dir $opts2)
66 COMPREPLY=( $(compgen -W "${opts2}" -- ${cur}) )
71 if [[ $appli != $prev ]]
73 opts=$(for x in `$SAT_PATH/sat config $appli --completion`
76 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
80 _salomeTools_complete()
82 if [[ "${SAT_PATH}x" == "x" ]]
87 local cur opts args command
90 cur="${COMP_WORDS[COMP_CWORD]}"
92 # second argument => show available APPLICATION
95 command="${COMP_WORDS[1]}"
100 if [[ ${command%%-*} == "" ]]
102 command="${COMP_WORDS[2]}"
103 argc="$((( argc - 1)))"
107 # first argument => show available commands
108 if [[ ${argc} == 1 ]]
110 opts="config log source patch prepare environ clean configure make makeinstall compile launcher run jobs job shell test package generate find_duplicates application template base check profile script init --help --overwrite --debug --verbose --batch --all_in_terminal --logs_paths_in_file"
111 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
115 if [[ ${argc} == 2 ]]
117 # get list of APPLICATIONS
122 # option depending on command
123 local prev="${COMP_WORDS[COMP_CWORD-1]}"
125 if [[ ${prev} == "--value" || ${prev} == "-v" ]]
127 if [[ ${argc} == 4 ]]
130 opts=$(for x in `$SAT_PATH/sat config ${COMP_WORDS[COMP_CWORD-2]} -s ${COMP_WORDS[COMP_CWORD]}`
132 COMPREPLY=( $(compgen -W "${opts}" -S "." -- ${cur}) )
134 # without application
135 opts=$(for x in `$SAT_PATH/sat config -s ${COMP_WORDS[COMP_CWORD]}`
137 COMPREPLY=( $(compgen -W "${opts}" -S "." -- ${cur}) )
143 # show list of products
144 if [[ ${prev} == "--products" || ${prev} == "-p" || ${prev} == "--info" || ${prev} == "-i" ]]
146 appli="${COMP_WORDS[2]}"
147 if [[ ${command} != "source" ]]
149 opts=$(for x in `$SAT_PATH/sat config $appli --completion`
152 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
157 # show argument for each command
160 opts="--value --list --copy --edit --no_label --info --show_patchs"
161 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
165 opts="--clean --last --terminal --last --last_terminal --no_browser"
166 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
170 opts="--products --sources --build --install --all --sources_without_dev --properties"
171 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
175 opts="--products --properties"
176 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
180 opts="--products --properties"
181 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
185 opts="--products --properties --force --force_patch"
186 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
190 opts="--products --shell --prefix --target"
191 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
195 opts="--products --option"
196 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
200 opts="--products --option"
201 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
206 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
210 opts="--products --properties --with_fathers --with_children --clean_all --clean_make --install_flags --show --stop_first_fail --check --clean_build_after"
211 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
215 opts="--name --catalog --gencat"
216 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
220 opts="--name --only_jobs --list --completion --test_connection --input_boards --publish"
221 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
226 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
230 opts="--jobs_config --name"
231 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
235 opts="--base --launcher --grid --session --display"
236 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
240 opts="--name --binaries --sources --project --salometools --force_creation --add_files --with_vcs --without_commercial --without_property"
241 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
245 opts="--products --yacsgen"
246 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
250 opts="--path --sources --exclude-file --exclude-extension --exclude-path"
251 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
255 opts="--name --catalog --target --gencat --module"
256 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
260 opts="--name --template --target --param --info"
261 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
266 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
270 opts="--prefix --name --force --no_update --version --slogan"
271 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
275 opts="--products --nb_proc"
276 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
281 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
285 opts="--base --workdir --VCS --tag --log_dir"
286 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
294 # activation of auto-completion for the sat command
295 complete -F _salomeTools_complete sat
296 complete -F _salomeTools_complete ./sat