| #!/bin/bash |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| function cli_printMessage { |
| |
| local MESSAGE="$1" |
| local FORMAT="$2" |
| |
| |
| if [[ $MESSAGE == '' ]];then |
| cli_printMessage "`gettext "The message cannot be empty."`" --as-error-line |
| fi |
| |
| |
| |
| |
| local MESSAGE_WIDTH=66 |
| |
| |
| MESSAGE=$(echo $MESSAGE | sed -r -e 's!^[[:space:]]+!!') |
| |
| |
| |
| case "$FORMAT" in |
| |
| --as-stdout-line ) |
| |
| |
| |
| |
| |
| |
| echo "$MESSAGE" | sed -r \ |
| -e "s!${TCAR_WORKDIR}/(trunk|branches|tags)/!\1/!g" \ |
| -e "s!/{2,}!/!g" \ |
| | awk 'BEGIN { FS=": " } |
| { |
| if ( $0 ~ /^-+$/ ) |
| print $0 |
| else |
| printf "%-15s\t%s\n", $1, $2 |
| } |
| END {}' |
| ;; |
| |
| --as-error-line ) |
| |
| |
| |
| |
| local ORIGIN="$(caller 1 | gawk '{ print $2 " L." $1 }')" |
| |
| |
| cli_printMessage "${CLI_NAME} (${ORIGIN}):" --as-stdout-line |
| cli_printMessage "${MESSAGE}" --as-response-line |
| cli_printMessage "${CLI_FUNCDIRNAM}" --as-toknowmore-line |
| |
| |
| |
| |
| |
| exit 1 |
| ;; |
| |
| --as-toknowmore-line ) |
| cli_printMessage '-' --as-separator-line |
| cli_printMessage "`gettext "To know more, run the following command"`:" --as-stdout-line |
| cli_printMessage "centos-art help --read trunk/Scripts/Functions/$MESSAGE" --as-stdout-line |
| cli_printMessage '-' --as-separator-line |
| ;; |
| |
| --as-yesornorequest-line ) |
| |
| |
| local Y="`gettext "yes"`" |
| |
| |
| local N="`gettext "no"`" |
| |
| |
| local ANSWER=${N} |
| |
| if [[ $FLAG_ANSWER == 'true' ]];then |
| |
| ANSWER=${Y} |
| |
| else |
| |
| |
| cli_printMessage "$MESSAGE [${Y}/${N}]" --as-request-line |
| |
| |
| read ANSWER |
| |
| fi |
| |
| |
| |
| |
| |
| if [[ ! ${ANSWER} =~ "^${Y}" ]];then |
| exit |
| fi |
| ;; |
| |
| --as-selection-line ) |
| |
| local NAME='' |
| select NAME in ${MESSAGE};do |
| echo $NAME |
| break |
| done |
| ;; |
| |
| --as-response-line ) |
| cli_printMessage "--> $MESSAGE" --as-stdout-line |
| ;; |
| |
| --as-request-line ) |
| cli_printMessage "${MESSAGE}:\040" --as-notrailingnew-line |
| ;; |
| |
| --as-notrailingnew-line ) |
| echo -e -n "${MESSAGE}" | sed -r \ |
| -e "s!${TCAR_WORKDIR}/(trunk|branches|tags)/!\1/!g" |
| ;; |
| |
| --as-stderr-line ) |
| echo "$MESSAGE" | sed -r \ |
| -e "s!${TCAR_WORKDIR}/(trunk|branches|tags)/!\1/!g" 1>&2 |
| ;; |
| |
| esac |
| |
| |
| |
| if [[ "$FLAG_QUIET" == 'true' ]];then |
| return |
| fi |
| |
| |
| |
| case "$FORMAT" in |
| |
| --as-separator-line ) |
| |
| |
| MESSAGE=$(\ |
| until [[ $MESSAGE_WIDTH -eq 0 ]];do |
| echo -n "$(echo $MESSAGE | sed -r 's!(.).*!\1!')" |
| MESSAGE_WIDTH=$(($MESSAGE_WIDTH - 1)) |
| done) |
| |
| |
| echo "$MESSAGE" |
| ;; |
| |
| --as-banner-line ) |
| cli_printMessage '-' --as-separator-line |
| cli_printMessage "$MESSAGE" --as-stdout-line |
| cli_printMessage '-' --as-separator-line |
| ;; |
| |
| --as-cropping-line ) |
| cli_printMessage "`gettext "Cropping from"`: $MESSAGE" --as-stdout-line |
| ;; |
| |
| --as-tuningup-line ) |
| cli_printMessage "`gettext "Tuning-up"`: $MESSAGE" --as-stdout-line |
| ;; |
| |
| --as-checking-line ) |
| cli_printMessage "`gettext "Checking"`: $MESSAGE" --as-stdout-line |
| ;; |
| |
| --as-combining-line ) |
| cli_printMessage "`gettext "Combining"`: $MESSAGE" --as-stdout-line |
| ;; |
| |
| --as-creating-line | --as-updating-line ) |
| if [[ -a "$MESSAGE" ]];then |
| cli_printMessage "`gettext "Updating"`: $MESSAGE" --as-stdout-line |
| else |
| cli_printMessage "`gettext "Creating"`: $MESSAGE" --as-stdout-line |
| fi |
| ;; |
| |
| --as-deleting-line ) |
| cli_printMessage "`gettext "Deleting"`: $MESSAGE" --as-stdout-line |
| ;; |
| |
| --as-reading-line ) |
| cli_printMessage "`gettext "Reading"`: $MESSAGE" --as-stdout-line |
| ;; |
| |
| --as-savedas-line ) |
| cli_printMessage "`gettext "Saved as"`: $MESSAGE" --as-stdout-line |
| ;; |
| |
| --as-linkto-line ) |
| cli_printMessage "`gettext "Linked to"`: $MESSAGE" --as-stdout-line |
| ;; |
| |
| --as-movedto-line ) |
| cli_printMessage "`gettext "Moved to"`: $MESSAGE" --as-stdout-line |
| ;; |
| |
| --as-translation-line ) |
| cli_printMessage "`gettext "Translation"`: $MESSAGE" --as-stdout-line |
| ;; |
| |
| --as-validating-line ) |
| cli_printMessage "`gettext "Validating"`: $MESSAGE" --as-stdout-line |
| ;; |
| |
| --as-template-line ) |
| cli_printMessage "`gettext "Template"`: $MESSAGE" --as-stdout-line |
| ;; |
| |
| --as-configuration-line ) |
| cli_printMessage "`gettext "Configuration"`: $MESSAGE" --as-stdout-line |
| ;; |
| |
| --as-palette-line ) |
| cli_printMessage "`gettext "Palette"`: $MESSAGE" --as-stdout-line |
| ;; |
| |
| --as-inkscape-line ) |
| cli_printMessage "$MESSAGE" --as-stdout-line |
| ;; |
| |
| esac |
| |
| } |