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 products
32 opts2=$(echo --list --value --edit --info $opts2)
35 opts2=$(echo --clean --full --last --terminal $opts2)
39 COMPREPLY=( $(compgen -W "${opts2}" -- ${cur}) )
42 _salomeTools_complete()
44 if [[ "${SAT_PATH}x" == "x" ]]
49 local cur opts args command
52 cur="${COMP_WORDS[COMP_CWORD]}"
54 # second argument => show available APPLICATION
57 command="${COMP_WORDS[1]}"
62 if [[ ${command%%-*} == "" ]]
64 command="${COMP_WORDS[2]}"
65 argc="$((( argc - 1)))"
69 # first argument => show available commands
72 opts="config log testcommand --help"
73 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
79 # get list of APPLICATIONS
84 # option depending on command
85 local prev="${COMP_WORDS[COMP_CWORD-1]}"
87 if [[ ${prev} == "--value" || ${prev} == "-v" ]]
92 opts=$(for x in `$SAT_PATH/sat config ${COMP_WORDS[COMP_CWORD-2]} -s ${COMP_WORDS[COMP_CWORD]}`
94 COMPREPLY=( $(compgen -W "${opts}" -S "." -- ${cur}) )
97 opts=$(for x in `$SAT_PATH/sat config -s ${COMP_WORDS[COMP_CWORD]}`
99 COMPREPLY=( $(compgen -W "${opts}" -S "." -- ${cur}) )
105 # show list of softwares
106 if [[ ${prev} == "--module" || ${prev} == "-m" ]]
108 prod="${COMP_WORDS[2]}"
109 if [[ ${command} != "test" ]]
111 opts=$(for x in `$SAT_PATH/sat config $prod -nv PRODUCT.softwares`
114 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
119 # show argument for each command
122 opts="--value --list --copy --edit --no_label"
123 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
127 opts="--clean --last --terminal --last"
128 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
136 # activation de l'auto-completion pour la commande sat
137 complete -F _salomeTools_complete sat
138 complete -F _salomeTools_complete ./sat