2018-03-09 05:42:45 +02:00
|
|
|
#!/usr/bin/env bash
|
2018-05-10 09:46:34 +03:00
|
|
|
# Copyright 2018 Slightech Co., Ltd. All rights reserved.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
2018-03-08 09:54:14 +02:00
|
|
|
|
|
|
|
[ -n "${_ECHO_SH_}" ] && return || readonly _ECHO_SH_=1
|
|
|
|
[ -n "${_VERBOSE_}" ] && echo "-- INCLUDE: echo.sh"
|
|
|
|
|
|
|
|
# if [ -n "$SCRIPTS_DIR" ]; then
|
|
|
|
# source "$SCRIPTS_DIR/common/echo.sh"
|
|
|
|
# else
|
|
|
|
# source "$(dirname "$0")/echo.sh"
|
|
|
|
# fi
|
|
|
|
|
2018-03-09 05:42:45 +02:00
|
|
|
ECHO="echo -e"
|
2018-03-08 09:54:14 +02:00
|
|
|
|
|
|
|
# task colors
|
|
|
|
COLOR_STRONG="1;35" # Magenta
|
|
|
|
COLOR_INFO="1;34" # Blue
|
2018-11-01 17:12:36 +02:00
|
|
|
COLOR_WARN="1;33" # Yellow
|
2018-03-08 09:54:14 +02:00
|
|
|
COLOR_DONE="1;32" # Green
|
|
|
|
COLOR_ERROR="1;31" # Red
|
|
|
|
# action colors
|
2018-03-09 04:51:09 +02:00
|
|
|
COLOR_STRONG_NORMAL="35"
|
2018-03-08 09:54:14 +02:00
|
|
|
COLOR_INFO_NORMAL="34"
|
2018-11-01 17:12:36 +02:00
|
|
|
COLOR_WARN_NORMAL="33"
|
2018-03-08 09:54:14 +02:00
|
|
|
COLOR_DONE_NORMAL="32"
|
|
|
|
COLOR_ERROR_NORMAL="31"
|
|
|
|
|
|
|
|
_echo_() {
|
|
|
|
text="$1"; shift; options="$1"; shift;
|
|
|
|
[ -z "$options" ] && options="$COLOR_STRONG";
|
|
|
|
$ECHO "\033[${options}m${text}\033[0m"
|
|
|
|
}
|
|
|
|
|
|
|
|
_echo_e_() {
|
|
|
|
text="$1"; shift; options="$1"; shift;
|
|
|
|
[ -z "$options" ] && options="$COLOR_ERROR";
|
|
|
|
$ECHO >&2 "\033[${options}m${text}\033[0m"
|
|
|
|
}
|
|
|
|
|
|
|
|
_echo() {
|
|
|
|
$ECHO "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
_echo_s() {
|
|
|
|
_echo_ "$1" "$COLOR_STRONG"
|
|
|
|
}
|
|
|
|
|
|
|
|
_echo_i() {
|
|
|
|
_echo_ "$1" "$COLOR_INFO"
|
|
|
|
}
|
|
|
|
|
2018-11-01 17:12:36 +02:00
|
|
|
_echo_w() {
|
|
|
|
_echo_ "$1" "$COLOR_WARN"
|
|
|
|
}
|
|
|
|
|
2018-03-08 09:54:14 +02:00
|
|
|
_echo_d() {
|
|
|
|
_echo_ "$1" "$COLOR_DONE"
|
|
|
|
}
|
|
|
|
|
|
|
|
_echo_e() {
|
|
|
|
_echo_e_ "$1" "$COLOR_ERROR"
|
|
|
|
}
|
|
|
|
|
2018-03-09 04:51:09 +02:00
|
|
|
_echo_sn() {
|
|
|
|
_echo_ "$1" "$COLOR_STRONG_NORMAL"
|
|
|
|
}
|
|
|
|
|
2018-03-08 09:54:14 +02:00
|
|
|
_echo_in() {
|
|
|
|
_echo_ "$1" "$COLOR_INFO_NORMAL"
|
|
|
|
}
|
|
|
|
|
2018-11-01 17:12:36 +02:00
|
|
|
_echo_wn() {
|
|
|
|
_echo_ "$1" "$COLOR_WARN_NORMAL"
|
|
|
|
}
|
|
|
|
|
2018-03-08 09:54:14 +02:00
|
|
|
_echo_dn() {
|
|
|
|
_echo_ "$1" "$COLOR_DONE_NORMAL"
|
|
|
|
}
|
|
|
|
|
|
|
|
_echo_en() {
|
|
|
|
_echo_e_ "$1" "$COLOR_ERROR_NORMAL"
|
|
|
|
}
|