From eeb4ba2d79bc52f6dc4dd512a340a2dd2da73cb0 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Tue, 19 Sep 2017 12:10:53 +0200 Subject: [PATCH] Unify scripts by using a common color / function framework Signed-off-by: Knut Ahlers --- bin/git-c | 7 +------ bin/git-pot | 7 +------ bin/git-ps | 7 +------ bin/script_framework.sh | 20 ++++++++++++++++++++ bin/vault-sshadd | 17 +---------------- 5 files changed, 24 insertions(+), 34 deletions(-) create mode 100644 bin/script_framework.sh diff --git a/bin/git-c b/bin/git-c index b13824a..809a62c 100755 --- a/bin/git-c +++ b/bin/git-c @@ -3,12 +3,7 @@ set -o pipefail set -e -STEP_COLOR="\033[0;36m" -NO_COLOR="\033[0m" - -function step { - echo -e ${STEP_COLOR}[$(date +%H:%M:%S)] $1${NO_COLOR} -} +source "${HOME}/bin/script_framework.sh" ### Fix committer email by repo diff --git a/bin/git-pot b/bin/git-pot index b5c4f65..84c9fbb 100755 --- a/bin/git-pot +++ b/bin/git-pot @@ -3,12 +3,7 @@ set -o pipefail set -e -STEP_COLOR="\033[0;36m" -NO_COLOR="\033[0m" - -function step { - echo -e ${STEP_COLOR}[$(date +%H:%M:%S)] $1${NO_COLOR} -} +source "${HOME}/bin/script_framework.sh" ### Determine what to push diff --git a/bin/git-ps b/bin/git-ps index dc2c7be..2a58b6d 100755 --- a/bin/git-ps +++ b/bin/git-ps @@ -3,12 +3,7 @@ set -o pipefail set -e -STEP_COLOR="\033[0;36m" -NO_COLOR="\033[0m" - -function step { - echo -e ${STEP_COLOR}[$(date +%H:%M:%S)] $1${NO_COLOR} -} +source "${HOME}/bin/script_framework.sh" step "Loading required keys to pull" git loadkey diff --git a/bin/script_framework.sh b/bin/script_framework.sh new file mode 100644 index 0000000..2ea22d7 --- /dev/null +++ b/bin/script_framework.sh @@ -0,0 +1,20 @@ +COLOR_RED="\033[0;31m" +COLOR_GREEN="\033[0;32m" +COLOR_CYAN="\033[0;36m" +COLOR_PLAIN="\033[0m" + +function error { + echo -e "${COLOR_RED}$@${COLOR_PLAIN}" +} + +function success { + echo -e "${COLOR_GREEN}$@${COLOR_PLAIN}" +} + +function info { + echo -e "${COLOR_CYAN}$@${COLOR_PLAIN}" +} + +function step { + info "[$(date +%H:%M:%S)] $@" +} diff --git a/bin/vault-sshadd b/bin/vault-sshadd index b2b816d..e65444a 100755 --- a/bin/vault-sshadd +++ b/bin/vault-sshadd @@ -3,22 +3,7 @@ set -e set -o pipefail -COLOR_RED="\033[0;31m" -COLOR_GREEN="\033[0;32m" -COLOR_CYAN="\033[0;36m" -COLOR_PLAIN="\033[0m" - -function error { - echo -e "${COLOR_RED}$@${COLOR_PLAIN}" -} - -function success { - echo -e "${COLOR_GREEN}$@${COLOR_PLAIN}" -} - -function info { - echo -e "${COLOR_CYAN}$@${COLOR_PLAIN}" -} +source "${HOME}/bin/script_framework.sh" if ! ( which vault > /dev/null ); then error "vault is required."