linting
This commit is contained in:
parent
f76eecc321
commit
5a2ed6c68d
1 changed files with 13 additions and 13 deletions
|
@ -5,9 +5,9 @@
|
||||||
# `source` can be relative to ~/.config/yadm/ or full path.
|
# `source` can be relative to ~/.config/yadm/ or full path.
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# source=install yadm bootstrap
|
# source=install yadm bootstrap
|
||||||
# or
|
# or
|
||||||
# source=~/.config/yadm/install yadm bootstrap
|
# source=~/.config/yadm/install yadm bootstrap
|
||||||
#
|
#
|
||||||
# where `~/.config/yadm/install` can be like this:
|
# where `~/.config/yadm/install` can be like this:
|
||||||
#
|
#
|
||||||
|
@ -26,27 +26,27 @@ TEXT_COLOR_YELLOW=$(tput setaf 3)
|
||||||
TEXT_DEFAULT=$(tput sgr0)
|
TEXT_DEFAULT=$(tput sgr0)
|
||||||
|
|
||||||
info() {
|
info() {
|
||||||
printf "${TEXT_COLOR_BLUE}%s${TEXT_DEFAULT}" "$1"; "${@:2}"
|
printf "${TEXT_COLOR_BLUE}%s${TEXT_DEFAULT}" "$1"; "${@:2}"
|
||||||
}
|
}
|
||||||
|
|
||||||
error() {
|
error() {
|
||||||
printf "${TEXT_COLOR_RED}%s${TEXT_DEFAULT}" "$1"; "${@:2}"
|
printf "${TEXT_COLOR_RED}%s${TEXT_DEFAULT}" "$1"; "${@:2}"
|
||||||
}
|
}
|
||||||
|
|
||||||
success() {
|
success() {
|
||||||
printf "${TEXT_COLOR_GREEN}%s${TEXT_DEFAULT}" "$1"; "${@:2}"
|
printf "${TEXT_COLOR_GREEN}%s${TEXT_DEFAULT}" "$1"; "${@:2}"
|
||||||
}
|
}
|
||||||
|
|
||||||
warning() {
|
warning() {
|
||||||
printf "${TEXT_COLOR_YELLOW}%s${TEXT_DEFAULT}" "$1"; "${@:2}"
|
printf "${TEXT_COLOR_YELLOW}%s${TEXT_DEFAULT}" "$1"; "${@:2}"
|
||||||
}
|
}
|
||||||
|
|
||||||
source_if_exists() {
|
source_if_exists() {
|
||||||
if [[ -f $1 ]]; then source "$1"; else return 1; fi
|
if [[ -f $1 ]]; then source "$1"; else return 1; fi
|
||||||
}
|
}
|
||||||
|
|
||||||
command_exists () {
|
command_exists () {
|
||||||
command -v "$1" &> /dev/null
|
command -v "$1" &> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
# install a 'command' via 'code' if it was not previously installed yet
|
# install a 'command' via 'code' if it was not previously installed yet
|
||||||
|
@ -68,13 +68,13 @@ confirm() {
|
||||||
local default_answer="${1:-no}"
|
local default_answer="${1:-no}"
|
||||||
local code=$2
|
local code=$2
|
||||||
local message=$3
|
local message=$3
|
||||||
local options answer
|
local options answer
|
||||||
|
|
||||||
if [[ "${default_answer:0:1}" == y* ]]; then
|
if [[ "${default_answer:0:1}" == y* ]]; then
|
||||||
options="$(success 'YES')/no"
|
options="$(success 'YES')/no"
|
||||||
else
|
else
|
||||||
options="yes/$(success 'NO')"
|
options="yes/$(success 'NO')"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
read -r -p "${message} [${options}]:" answer
|
read -r -p "${message} [${options}]:" answer
|
||||||
answer=${answer:-$default_answer}
|
answer=${answer:-$default_answer}
|
||||||
|
|
Loading…
Reference in a new issue