Commit 8bce4f29 authored by PENGUEN Julien's avatar PENGUEN Julien
Browse files

ajout function_message pour afficher les messages

parent 8da6e60d
......@@ -6,6 +6,156 @@
#-------- functions --------#
#---------------------------#
function_message()
{
# function_message: display message with input argument
# input error_message to display
type_message=$1
message=$2
if [ "$type_message" == "TYPE_VAL_ERROR" ]; then
echo ""
echo "------------------------------------"
echo ""
echo -e "\033[31m========================================================="
echo -e "WARNING => ${message}"
echo -e "=========================================================\033[0m"
elif [ "$type_message" == "TYPE_HELP" ]; then
echo ""
echo "------------------------------------"
echo ""
echo -e "\033[32m========"
echo -e "= HELP ="
echo -e "========\033[0m"
elif [ "$type_message" == "TYPE_UNKNOWN" ]; then
echo ""
echo -e "\033[31m==============================="
echo -e " error: unrecognized arguments "
echo -e "===============================\033[0m"
elif [ "$type_message" == "TYPE_EXIST_VERSION" ]; then
echo ''
echo -e "\033[31m===================================="
echo -e " WARNING"
echo -e "====================================\033[0m"
echo ''
echo '------------------------------------'
echo ''
echo "You must select an existing version"
echo " available on "
echo " https://aladin.u-strasbg.fr "
echo ''
echo 'To see the available version(s):'
echo ''
echo "Please make ./photos_montage_aladin.sh -i OR --infos"
echo ''
echo '------------------------------------'
echo ''
elif [ "$type_message" == "TYPE_FORCE_WARNING" ]; then
echo ''
echo -e "\033[31m===================================="
echo -e " WARNING"
echo -e "====================================\033[0m"
echo ''
echo '------------------------------------'
echo ''
echo "With option --force you must select an existing area"
echo ''
echo 'Please see the available area(s) on:'
echo ''
echo "${message}"
echo ''
echo '------------------------------------'
echo ''
elif [ "$type_message" == "TYPE_DELETE_EXIST_VERSION" ]; then
echo ''
echo -e "\033[31m===================================="
echo -e " WARNING"
echo -e "====================================\033[0m"
echo ''
echo '------------------------------------'
echo ''
echo "You must delete an existing version"
echo " available on the localhost "
echo ''
echo 'To see the available version(s):'
echo ''
echo "Please make ./photos_montage_aladin.sh -i OR --infos"
echo ''
echo '------------------------------------'
echo ''
elif [ "$type_message" == "TYPE_UPDATE" ]; then
echo ''
echo '========================================'
echo ' YOU ARE NOT USING THE LAST '
echo ' ALADIN VERSION '
echo '========================================'
echo ''
echo '=> A new ALADIN version is available:' ${message}
echo ''
echo 'COMMAND TO UPDATE ALADIN VERSION:'
echo ''
echo '=> ./photos_montage_aladin.sh -u OR --update'
echo '------------------------------------'
echo ''
echo ''
else
echo "BLA BLA"
fi
if [[ "$type_message" == "TYPE_VAL_ERROR" || "$type_message" == "TYPE_HELP" || "$type_message" == "TYPE_UNKNOWN" ]]; then
echo ""
echo "------------------------------------"
echo ""
echo "use : ./photos_montage_aladin.sh [options] [others]"
echo ""
echo ""
echo "OPTIONS:"
echo ""
echo "-i, --infos give informations about versions available on aladin server"
echo " and about photos_montage_aladin image present on localhost"
echo "-b version, --build version build photos_montage_aladin image with selected version"
echo "--select version run photos_montage_aladin with selected version number"
echo "--force-all re-run all areas in input csv"
echo "--force area re-run for the area, the area must be in input csv"
echo "-u, --update update photos_montage_aladin image version"
echo "-rm version, --remove version remove photos_montage_aladin image with selected version"
echo "-h, --help show this help message and exit"
echo "-v, --version give photos_montage_aladin.sh current version number"
echo ""
echo ""
echo "OTHERS:"
echo ""
echo "--survey file run photos_montage_aladin with this survey file instead of "
echo "the default file define on .env file. the survey file must be on format '.dat'"
echo "--area file run photos_montage_aladin with this survey file instead of "
echo "the default file define on .env file. the area file must be on format '.csv'"
echo ""
echo "--angular run photos_montage_aladin with this angular dimension value instead of "
echo "the default angular value define on .env file. the angular value must be on second of arc"
echo ""
fi
}
function_build_tab_hach()
{
# function_build_tab_hach: retrieve and organize $@
......@@ -283,24 +433,7 @@ function_build_image()
if [ $? -eq 1 ]; then
echo ''
echo -e "\033[31m===================================="
echo -e " WARNING"
echo -e "====================================\033[0m"
echo ''
echo '------------------------------------'
echo ''
echo "You must select an existing version"
echo " available on "
echo " https://aladin.u-strasbg.fr "
echo ''
echo 'To see the available version(s):'
echo ''
echo "Please make ./photos_montage_aladin.sh -i OR --infos"
echo ''
echo '------------------------------------'
echo ''
function_message "TYPE_EXIST_VERSION"
exit 0
......@@ -428,45 +561,8 @@ val_error=`echo $RESULTAT | cut --delimiter=, -f 4`
if [ $val_error == "TRUE" ]; then
error_message=`echo $RESULTAT | cut --delimiter=, -f 5`
echo ""
echo "------------------------------------"
echo ""
echo -e "\033[31m========================================================="
echo -e "WARNING => ${error_message}"
echo -e "=========================================================\033[0m"
echo ""
echo "------------------------------------"
echo ""
echo "use : ./photos_montage_aladin.sh [options] [others]"
echo ""
echo ""
echo "OPTIONS:"
echo ""
echo "-i, --infos give informations about versions available on aladin server"
echo " and about photos_montage_aladin image present on localhost"
echo "-b version, --build version build photos_montage_aladin image with selected version"
echo "--select version run photos_montage_aladin with selected version number"
echo "--force-all re-run all areas in input csv"
echo "--force area re-run for the area, the area must be in input csv"
echo "-u, --update update photos_montage_aladin image version"
echo "-rm version, --remove version remove photos_montage_aladin image with selected version"
echo "-h, --help show this help message and exit"
echo "-v, --version give photos_montage_aladin.sh current version number"
echo ""
echo ""
echo "OTHERS:"
echo ""
echo "--survey file run photos_montage_aladin with this survey file instead of "
echo "the default file define on .env file. the survey file must be on format '.dat'"
echo "--area file run photos_montage_aladin with this survey file instead of "
echo "the default file define on .env file. the area file must be on format '.csv'"
echo "--angular run photos_montage_aladin with this angular dimension value instead of "
echo "the default angular value define on .env file. the angular value must be on second of arc"
echo ""
echo "------------------------------------"
echo ""
function_message "TYPE_VAL_ERROR" "${error_message}"
exit 0
fi
#------------------------------------#
......@@ -507,8 +603,8 @@ case $taille in
elif [ "${tempo_arg_weight[0]}" -eq 1 ]; then
#case option with weight=1
if [ "${tempo_arg_keys[0]}" == '--force-all' ]; then
#case '--force_all'
if [[ "${tempo_arg_keys[0]}" == '--force-all' || "${tempo_arg_keys[0]}" == '--force' ]]; then
#case '--force_all', '--force'
tab2_arg_keys[0]="--no_select"
tab2_arg_values[0]="$ALADIN_VERSION"
......@@ -652,9 +748,6 @@ if [[ "${sort_arg_keys[@]}" =~ "--area" ]]; then
INPUT_FILE_AREAS=${sort_arg_values[$RESULT_INDICE_AREA]}
fi
echo "=> use ${INPUT_FILE_SURVEYS}"
echo "=> use ${INPUT_FILE_AREAS}"
#-------------------------------------#
#check angular input arg
......@@ -663,17 +756,14 @@ if [[ "${sort_arg_keys[@]}" =~ "--angular" ]]; then
ANGULAR=${sort_arg_values[$RESULT_INDICE_ANGULAR]}
fi
echo "=> use ${ANGULAR}"
#---------------------#
# --no_select management
#---------------------#
# --no_select management
if [ "${sort_arg_keys[0]}" == "--no_select" ]; then
sort_arg_keys[0]=""
sort_arg_values[0]=""
sort_arg_weight[0]=0
fi
if [ "${sort_arg_keys[0]}" == "--no_select" ]; then
sort_arg_keys[0]=""
sort_arg_values[0]=""
sort_arg_weight[0]=0
fi
#---------------------#
......@@ -734,25 +824,8 @@ case ${sort_arg_keys[0]} in
if [ $? -eq 1 ]; then
echo ''
echo -e "\033[31m===================================="
echo -e " WARNING"
echo -e "====================================\033[0m"
echo ''
echo '------------------------------------'
echo ''
echo "You must select an existing version"
echo " available on "
echo " https://aladin.u-strasbg.fr "
echo ''
echo 'To see the available version(s):'
echo ''
echo "Please make ./photos_montage_aladin.sh -i OR --infos"
echo ''
echo '------------------------------------'
echo ''
exit 0
function_message "TYPE_EXIST_VERSION"
exit 0
else
......@@ -784,21 +857,7 @@ case ${sort_arg_keys[0]} in
if [ ${aladin_last_number_version} != ${version} ]; then
echo ''
echo '========================================'
echo ' YOU ARE NOT USING THE LAST '
echo ' ALADIN VERSION '
echo '========================================'
echo ''
echo '=> A new ALADIN version is available:' ${aladin_last_number_version}
echo ''
echo 'COMMAND TO UPDATE ALADIN VERSION:'
echo ''
echo '=> ./photos_montage_aladin.sh -u OR --update'
echo '------------------------------------'
echo ''
echo ''
function_message "TYPE_UPDATE" "${aladin_last_number_version}"
sleep 5
else
......@@ -1085,23 +1144,8 @@ case ${sort_arg_keys[0]} in
#------------------------#
if [ "${force_warning}" == 'TRUE' ]; then
echo ''
echo -e "\033[31m===================================="
echo -e " WARNING"
echo -e "====================================\033[0m"
echo ''
echo '------------------------------------'
echo ''
echo "With option --force you must select an existing area"
echo ''
echo 'Please see the available area(s) on:'
echo ''
echo "${INPUT_FILE_AREAS}"
echo ''
echo '------------------------------------'
echo ''
exit 0
function_message "TYPE_FORCE_WARNING" "${INPUT_FILE_AREAS}"
exit 0
fi
......@@ -1132,24 +1176,10 @@ case ${sort_arg_keys[0]} in
present=$(echo $list_jar| grep "${version}")
if [ $? -eq 1 ]; then
echo ''
echo -e "\033[31m===================================="
echo -e " WARNING"
echo -e "====================================\033[0m"
echo ''
echo '------------------------------------'
echo ''
echo "You must select an existing version"
echo " available on "
echo " https://aladin.u-strasbg.fr "
echo ''
echo 'To see the available version(s):'
echo ''
echo "Please make ./photos_montage_aladin.sh -i OR --infos"
echo ''
echo '------------------------------------'
echo ''
function_message "TYPE_EXIST_VERSION"
exit 0
fi
......@@ -1309,22 +1339,7 @@ case ${sort_arg_keys[0]} in
if [ $? -eq 1 ]; then
echo ''
echo -e "\033[31m===================================="
echo -e " WARNING"
echo -e "====================================\033[0m"
echo ''
echo '------------------------------------'
echo ''
echo "You must delete an existing version"
echo " available on the localhost "
echo ''
echo 'To see the available version(s):'
echo ''
echo "Please make ./photos_montage_aladin.sh -i OR --infos"
echo ''
echo '------------------------------------'
echo ''
function_message "TYPE_DELETE_EXIST_VERSION"
exit 0
else
......@@ -1339,83 +1354,16 @@ case ${sort_arg_keys[0]} in
# use: ./photos_montage_aladin.sh -h OR --help #
################################################
echo ""
echo "====================="
echo ""
echo -e "\033[32m========"
echo -e "= HELP ="
echo -e "========\033[0m"
echo ""
echo "use : ./photos_montage_aladin.sh [options] [others]"
echo ""
echo ""
echo "OPTIONS:"
echo ""
echo "-i, --infos give informations about versions available on aladin server"
echo " and about photos_montage_aladin image present on localhost"
echo "-b version, --build version build photos_montage_aladin image with selected version"
echo "--select version run photos_montage_aladin with selected version number"
echo "--force-all re-run for all areas in input csv"
echo "--force area re-run for the area, the area must be in input csv"
echo "-u, --update update photos_montage_aladin image version"
echo "-rm version, --remove version remove photos_montage_aladin image with selected version"
echo "-h, --help show this help message and exit"
echo "-v, --version give photos_montage_aladin.sh current version number"
echo ""
echo ""
echo "OTHERS:"
echo ""
echo "--survey file run photos_montage_aladin with this survey file instead of "
echo "the default file define on .env file. the survey file must be on format '.dat'"
echo "--area file run photos_montage_aladin with this survey file instead of "
echo "the default file define on .env file. the area file must be on format '.csv'"
echo ""
echo "--angular run photos_montage_aladin with this angular dimension value instead of "
echo "the default angular value define on .env file. the angular value must be on second of arc"
echo "====================="
echo ""
;;
function_message "TYPE_HELP"
;;
*)
#################################################
# use: ./photos_montage_aladin.sh OTHER COMMAND #
#################################################
echo ""
echo -e "\033[31m==============================="
echo -e " error: unrecognized arguments "
echo -e "===============================\033[0m"
echo ""
echo "use : ./photos_montage_aladin.sh [options] [others]"
echo ""
echo ""
echo "OPTIONS:"
echo ""
echo "-i, --infos give informations about versions available on aladin server"
echo " and about photos_montage_aladin image present on localhost"
echo "-b version, --build version build photos_montage_aladin image with selected version"
echo "--select version run photos_montage_aladin with selected version number"
echo "--force-all re-run all areas in input csv"
echo "--force area re-run for the area, the area must be in input csv"
echo "-u, --update update photos_montage_aladin image version"
echo "-rm version, --remove version remove photos_montage_aladin image with selected version"
echo "-h, --help show this help message and exit"
echo "-v, --version give photos_montage_aladin.sh current version number"
echo ""
echo ""
echo "OTHERS:"
echo ""
echo "--survey file run photos_montage_aladin with this survey file instead of "
echo "the default file define on .env file. the survey file must be on format '.dat'"
echo "--area file run photos_montage_aladin with this survey file instead of "
echo "the default file define on .env file. the area file must be on format '.csv'"
echo ""
echo "--angular run photos_montage_aladin with this angular dimension value instead of "
echo "the default angular value define on .env file. the angular value must be on second of arc"
echo "====================="
echo ""
;;
function_message "TYPE_UNKNOWN"
;;
esac
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment