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)
57 COMPREPLY=( $(compgen -W "${opts2}" -- ${cur}) )
62 if [[ $appli != $prev ]]
64 opts=$(for x in `$SAT_PATH/sat -s config $appli -nv APPLICATION.products`
67 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
71 _salomeTools_complete()
73 if [[ "${SAT_PATH}x" == "x" ]]
78 local cur opts args command
81 cur="${COMP_WORDS[COMP_CWORD]}"
83 # second argument => show available APPLICATION
86 command="${COMP_WORDS[1]}"
91 if [[ ${command%%-*} == "" ]]
93 command="${COMP_WORDS[2]}"
94 argc="$((( argc - 1)))"
98 # first argument => show available commands
101 opts="config log testcommand source patch prepare environ clean configure make makeinstall compile launcher run jobs job shell test package generate find_duplicates --help"
102 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
106 if [[ ${argc} == 2 ]]
108 # get list of APPLICATIONS
113 # option depending on command
114 local prev="${COMP_WORDS[COMP_CWORD-1]}"
116 if [[ ${prev} == "--value" || ${prev} == "-v" ]]
118 if [[ ${argc} == 4 ]]
121 opts=$(for x in `$SAT_PATH/sat config ${COMP_WORDS[COMP_CWORD-2]} -s ${COMP_WORDS[COMP_CWORD]}`
123 COMPREPLY=( $(compgen -W "${opts}" -S "." -- ${cur}) )
125 # without application
126 opts=$(for x in `$SAT_PATH/sat config -s ${COMP_WORDS[COMP_CWORD]}`
128 COMPREPLY=( $(compgen -W "${opts}" -S "." -- ${cur}) )
134 # show list of products
135 if [[ ${prev} == "--product" || ${prev} == "-p" ]]
137 appli="${COMP_WORDS[2]}"
138 if [[ ${command} != "source" ]]
140 opts=$(for x in `$SAT_PATH/sat config $appli -nv APPLICATION.products`
143 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
148 # show argument for each command
151 opts="--value --list --copy --edit --no_label --info"
152 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
156 opts="--clean --last --terminal --last"
157 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
161 opts="--products --sources --build --install --all --sources_without_dev"
162 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
167 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
172 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
176 opts="--products --force --force_patch"
177 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
181 opts="--products --shell --prefix --target"
182 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
186 opts="--products --option"
187 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
191 opts="--products --option"
192 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
197 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
201 opts="--products --with_fathers --with_children --clean_all --make_flags --show --stop_first_fail"
202 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
206 opts="--name --catalog --gencat"
207 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
211 opts="--name --only_jobs --list --completion --test_connection --input_boards --publish"
212 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
217 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
221 opts="--jobs_config --name"
222 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
226 opts="--base --launcher --grid --session --display"
227 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
231 opts="--name --binaries --sources --project --salometools --with_vcs"
232 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
236 opts="--products --yacsgen"
237 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
241 opts="--path --sources --exclude-file --exclude-extension --exclude-path"
242 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
250 # activation of auto-completion for the sat command
251 complete -F _salomeTools_complete sat
252 complete -F _salomeTools_complete ./sat