foamGenerateBashCompletion: customise the -region option

This commit is contained in:
Chris Greenshields
2024-12-12 17:39:48 +00:00
parent 3b72908bd8
commit ce94118bbc

View File

@ -101,6 +101,14 @@ EOF
optionFunctions () { optionFunctions () {
cat<<EOF cat<<EOF
_region ()
{
find . -name polyMesh -type d | \
awk -F '/' '{print \$(NF-1)}' | \
grep -v constant | \
sort -u | xargs
}
_solver () _solver ()
{ {
foamToC -table solver | sed '1,/Contents/d' | awk '{print \$1}' | xargs foamToC -table solver | sed '1,/Contents/d' | awk '{print \$1}' | xargs
@ -296,7 +304,7 @@ $(declareLocals)
echo "\${_files}" | xargs -n 1 | sort -u echo "\${_files}" | xargs -n 1 | sort -u
} }
opts="-case -ext -help -no-ext -target" opts="-case -ext -help -no-ext -target -region"
for o in \$used ; do opts="\${opts/\$o/}" ; done for o in \$used ; do opts="\${opts/\$o/}" ; done
extra="" extra=""
opts="\${opts} \$(_searchDirs)" opts="\${opts} \$(_searchDirs)"
@ -306,10 +314,12 @@ $(caseStart)
opts="" ; extra="-d" ;; opts="" ; extra="-d" ;;
-ext) -ext)
opts="" ; extra="" ;; opts="" ; extra="" ;;
-region)
opts="\$(_region)"; extra="" ;;
-*) ;; -*) ;;
*) *)
case "\${COMP_WORDS[COMP_CWORD-2]}" in case "\${COMP_WORDS[COMP_CWORD-2]}" in
-case|-ext|-target) ;; -case|-ext|-target|-region) ;;
*) opts=""; extra="" ;; *) opts=""; extra="" ;;
esac esac
;; ;;
@ -472,7 +482,7 @@ do
handlerOpts="" # file handler options -fileHandler handlerOpts="" # file handler options -fileHandler
rangesOpts="" # ranges options -time rangesOpts="" # ranges options -time
argOpts="" # options with unspecified arguments argOpts="" # options with unspecified arguments
specialOpts="" # -solver, -table, -func specialOpts="" # -solver, -table, -func, -region
while read -r line while read -r line
do do
@ -489,7 +499,7 @@ do
[ "$opt" = "-libs" ] && next=libList [ "$opt" = "-libs" ] && next=libList
case "$opt" in case "$opt" in
-solver|-table|-func) -solver|-table|-func|-region)
specialOpts="$specialOpts $opt" specialOpts="$specialOpts $opt"
continue continue
;; ;;