mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: adjust 'No completions' message for more clarification
- Now state "[ignore if OpenFOAM is not yet compiled]"
This commit is contained in:
@ -5,11 +5,10 @@
|
|||||||
# \\ / A nd | www.openfoam.com
|
# \\ / A nd | www.openfoam.com
|
||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Copyright (C) 2017-2018 OpenCFD Ltd.
|
# Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
# This file is part of OpenFOAM, licensed under GNU General Public License
|
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
# <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
#
|
||||||
# File
|
# File
|
||||||
# etc/config.sh/bash_completion
|
# etc/config.sh/bash_completion
|
||||||
@ -58,20 +57,20 @@ foamAddCompletion()
|
|||||||
if [ "$appName" = "-clear" ]
|
if [ "$appName" = "-clear" ]
|
||||||
then
|
then
|
||||||
# Clear cached values
|
# Clear cached values
|
||||||
echo "clear cached values"
|
echo "clear cached values" 1>&2
|
||||||
_of_complete_cache_=()
|
_of_complete_cache_=()
|
||||||
|
|
||||||
elif [ "$appName" = "-list" ]
|
elif [ "$appName" = "-list" ]
|
||||||
then
|
then
|
||||||
# List cached keys
|
# List cached keys
|
||||||
choices="${#_of_complete_cache_[@]}"
|
choices="${#_of_complete_cache_[@]}"
|
||||||
echo "$choices cached values:"
|
echo "$choices cached values:" 1>&2
|
||||||
[ "$choices" = 0 ] || echo ${!_of_complete_cache_[@]} # keys
|
[ "$choices" = 0 ] || echo ${!_of_complete_cache_[@]} # keys
|
||||||
|
|
||||||
elif [ -d "$appName" ]
|
elif [ -d "$appName" ]
|
||||||
then
|
then
|
||||||
# Process directory for applications
|
# Process directory for applications
|
||||||
choices="$(find $appName -maxdepth 1 -executable -type f 2>/dev/null)"
|
choices="$(find "$appName" -maxdepth 1 -executable -type f 2>/dev/null)"
|
||||||
for appName in $choices
|
for appName in $choices
|
||||||
do
|
do
|
||||||
complete -o filenames -F _of_complete_ "${appName##*/}"
|
complete -o filenames -F _of_complete_ "${appName##*/}"
|
||||||
@ -82,9 +81,10 @@ foamAddCompletion()
|
|||||||
then
|
then
|
||||||
complete -o filenames -F _of_complete_ "${appName##*/}"
|
complete -o filenames -F _of_complete_ "${appName##*/}"
|
||||||
# echo "complete ${appName##*/}" 1>&2
|
# echo "complete ${appName##*/}" 1>&2
|
||||||
else
|
elif [ -n "$appName" ]
|
||||||
echo "No completion added for $appName" 1>&2
|
then
|
||||||
echo "... incorrect platform, or not yet compiled?" 1>&2
|
echo "No completions for $appName" 1>&2
|
||||||
|
echo "[ignore if OpenFOAM is not yet compiled]" 1>&2
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@ -124,7 +124,8 @@ _of_complete_()
|
|||||||
COMPREPLY=($(compgen -d -X '![-0-9]*' -- ${cur}))
|
COMPREPLY=($(compgen -d -X '![-0-9]*' -- ${cur}))
|
||||||
;;
|
;;
|
||||||
-region)
|
-region)
|
||||||
choices=$(\ls -d system/*/ 2>/dev/null | sed -e 's#/$##' -e 's#^.*/##')
|
# Or: $(find system -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sed -e 's%.*/%%')
|
||||||
|
choices=$(\ls -d system/*/ 2>/dev/null | sed -e 's%/$%%; s%^.*/%%')
|
||||||
COMPREPLY=($(compgen -W "$choices" -- ${cur}))
|
COMPREPLY=($(compgen -W "$choices" -- ${cur}))
|
||||||
;;
|
;;
|
||||||
-fileHandler)
|
-fileHandler)
|
||||||
@ -151,7 +152,8 @@ _of_complete_()
|
|||||||
# any of the option description text
|
# any of the option description text
|
||||||
if [ -z "$choices" ]
|
if [ -z "$choices" ]
|
||||||
then
|
then
|
||||||
local helpText=$($appName -help-full 2>/dev/null | \
|
local helpText
|
||||||
|
helpText=$("$appName" -help-full 2>/dev/null | \
|
||||||
sed -ne '1,/^[Oo]ptions:/d' \
|
sed -ne '1,/^[Oo]ptions:/d' \
|
||||||
-e '/^ \{8\}/d;' \
|
-e '/^ \{8\}/d;' \
|
||||||
-e 's/^ *//; /^$/d; /^[^-]/d; /^--/d; /^-help-man/d;' \
|
-e 's/^ *//; /^$/d; /^[^-]/d; /^--/d; /^-help-man/d;' \
|
||||||
@ -215,8 +217,8 @@ _of_complete_()
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
# Uses 'declare -gA' for the implementation
|
# Uses 'declare -gA' for the implementation
|
||||||
# The '-A' requires bash >= 4.0 and the '-g' requires bash >= 4.2
|
# The '-A' requires bash >= 4.0 and the '-g' requires bash >= 4.2
|
||||||
@ -231,9 +233,10 @@ then
|
|||||||
then
|
then
|
||||||
_of_complete_cache_=()
|
_of_complete_cache_=()
|
||||||
|
|
||||||
# Generate completions for predefined directories
|
# Completions for predefined directories
|
||||||
foamAddCompletion $FOAM_APPBIN
|
foamAddCompletion "$FOAM_APPBIN"
|
||||||
# And a few scripts from bin/
|
|
||||||
|
# A few scripts from bin/
|
||||||
foamAddCompletion paraFoam
|
foamAddCompletion paraFoam
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user