🔧 chore: merge #15 and fix conflicts
This commit is contained in:
+33
-14
@@ -1,13 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This script contains useful functions to be used
|
||||
# in other scripts from retrozindev's dotfiles.
|
||||
# in other scripts from colorshell.
|
||||
# ----------
|
||||
# Made by retrozinndev (João Dias)
|
||||
# Licensed under the MIT License
|
||||
# From: https://github.com/retrozinndev/colorshell
|
||||
|
||||
|
||||
# -------------
|
||||
# The repository's api url
|
||||
# -------------
|
||||
repo_api_url=https://api.github.com/repos/retrozinndev/colorshell
|
||||
|
||||
# -------------
|
||||
# Sends stdout log with type and message provided
|
||||
# in parameters.
|
||||
@@ -15,29 +20,22 @@
|
||||
# param $2 log message
|
||||
# -------------
|
||||
function Send_log() {
|
||||
log_message=$2
|
||||
log_message=`[[ -z $2 ]] && echo $1 || echo $2`
|
||||
color="\e[34m"
|
||||
log_type="info"
|
||||
|
||||
case ${1,,} in
|
||||
"^warn(ing)$")
|
||||
case "${1,,}" in
|
||||
warn)
|
||||
color="\e[33m"
|
||||
log_type="warning"
|
||||
;;
|
||||
|
||||
"^err(or)$")
|
||||
err)
|
||||
color="\e[31m"
|
||||
log_type="error"
|
||||
;;
|
||||
|
||||
*)
|
||||
color="\e[34m"
|
||||
log_type="info"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ -z $2 ]]; then
|
||||
log_message=$1
|
||||
fi
|
||||
|
||||
echo -e "${color}[$log_type]\e[0m $log_message"
|
||||
}
|
||||
|
||||
@@ -52,3 +50,24 @@ function Print_header() {
|
||||
echo "#############################"
|
||||
printf "\n"
|
||||
}
|
||||
|
||||
# -------------
|
||||
# Ask a yes/no question to user
|
||||
# Input answer is exported as $answer
|
||||
# -------------
|
||||
function Ask() {
|
||||
read -n 1 -p "$1 [y/n] " r
|
||||
printf '\n'
|
||||
export answer=$r
|
||||
}
|
||||
|
||||
# -------------
|
||||
# Ask a yes/no question to user
|
||||
# Input answer is exported as $answer
|
||||
# (this function is not done yet)
|
||||
# -------------
|
||||
function Choose() {
|
||||
read -n 1 -p "$1 [y/n] " r
|
||||
printf '\n'
|
||||
export answer=$r
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user