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)
51 COMPREPLY=( $(compgen -W "${opts2}" -- ${cur}) )
56 if [[ $appli != $prev ]]
58 opts=$(for x in `$SAT_PATH/sat -s config $appli -nv APPLICATION.products`
61 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
65 _salomeTools_complete()
67 if [[ "${SAT_PATH}x" == "x" ]]
72 local cur opts args command
75 cur="${COMP_WORDS[COMP_CWORD]}"
77 # second argument => show available APPLICATION
80 command="${COMP_WORDS[1]}"
85 if [[ ${command%%-*} == "" ]]
87 command="${COMP_WORDS[2]}"
88 argc="$((( argc - 1)))"
92 # first argument => show available commands
95 opts="config log testcommand source patch prepare environ clean configure make makeinstall compile launcher run jobs job shell test --help"
96 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
100 if [[ ${argc} == 2 ]]
102 # get list of APPLICATIONS
107 # option depending on command
108 local prev="${COMP_WORDS[COMP_CWORD-1]}"
110 if [[ ${prev} == "--value" || ${prev} == "-v" ]]
112 if [[ ${argc} == 4 ]]
115 opts=$(for x in `$SAT_PATH/sat config ${COMP_WORDS[COMP_CWORD-2]} -s ${COMP_WORDS[COMP_CWORD]}`
117 COMPREPLY=( $(compgen -W "${opts}" -S "." -- ${cur}) )
119 # without application
120 opts=$(for x in `$SAT_PATH/sat config -s ${COMP_WORDS[COMP_CWORD]}`
122 COMPREPLY=( $(compgen -W "${opts}" -S "." -- ${cur}) )
128 # show list of products
129 if [[ ${prev} == "--product" || ${prev} == "-p" ]]
131 appli="${COMP_WORDS[2]}"
132 if [[ ${command} != "source" ]]
134 opts=$(for x in `$SAT_PATH/sat config $appli -nv APPLICATION.products`
137 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
142 # show argument for each command
145 opts="--value --list --copy --edit --no_label --info"
146 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
150 opts="--clean --last --terminal --last"
151 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
155 opts="--products --sources --build --install --all --sources_without_dev"
156 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
161 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
166 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
170 opts="--products --force --force_patch"
171 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
175 opts="--products --shell --prefix --target"
176 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
180 opts="--products --option"
181 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
185 opts="--products --option"
186 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
191 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
195 opts="--products --with_fathers --with_children --clean_all --make_flags --show --stop_first_fail"
196 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
200 opts="--name --catalog --gencat"
201 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
205 opts="--name --only_jobs --list --completion --test_connection --input_boards --publish"
206 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
211 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
215 opts="--jobs_config --name"
216 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
220 opts="--base --launcher --grid --session --display"
221 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
229 # activation of auto-completion for the sat command
230 complete -F _salomeTools_complete sat
231 complete -F _salomeTools_complete ./sat