Skip to content

Commit

Permalink
feat(modules): adds previous code
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel De Lucca authored Apr 17, 2021
1 parent fa9a8f8 commit d37f43b
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
6 changes: 6 additions & 0 deletions modules/authorization.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

function update_su_timestamp {
sudo -k
sudo -v
}
49 changes: 49 additions & 0 deletions modules/feedback.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash

# Imports
# -------------------------------------------------------------------------------------------------

source <(curl -s https://raw.githubusercontent.com/tlatsas/bash-spinner/master/spinner.sh)

# -------------------------------------------------------------------------------------------------

function start_spinner_in_category {
category=$1
message=$2

full_message=" \x1B[36m\r➤\e[1m ${category}:\x1B[0m ${message}"

start_spinner "${full_message}"
}

function log_title {
message=$1

bold=$(tput bold)
reset=$(tput sgr0)
magenta=$(tput setaf 5)
number_of_columns="$(($(tput cols)-27))"
separator_spaces=$(printf "%${number_of_columns}s")

echo
echo "${bold}${magenta}${message}${reset}"
echo ${separator_spaces// /-}
}

function log_error {
message=$1

bold=$(tput bold)
reset=$(tput sgr0)
red=$(tput setaf 1)

echo "${bold}${red}Error:${reset}"
echo "${red} ${message}${reset}"
}

function throw_error {
message=$1

log_error "${message}"
exit 1
}
18 changes: 18 additions & 0 deletions modules/validation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

# Imports
# -------------------------------------------------------------------------------------------------

source <(https://raw.githubusercontent.com/delucca/shell-functions/1.0.0/modules/feedback.sh)

# Helpers
# -------------------------------------------------------------------------------------------------

function validate_bash_dependency {
major_version="$(bash --version | head -1 | cut -d ' ' -f 4 | cut -d '.' -f 1)"
min_major_version="4"

if [ "${major_version}" -lt "${min_major_version}" ]; then
throw_error "Your bash major version must be ${min_major_version} or greater"
fi
}

0 comments on commit d37f43b

Please sign in to comment.