Skip to content

Commit

Permalink
Improve scripts and update dependencies (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonmestevao authored Mar 3, 2023
1 parent c54c655 commit 2a0d318
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.10.4
3.10.7
33 changes: 33 additions & 0 deletions bin/server
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,39 @@ cd "${BASE_DIR}/.." || exit 127
# shellcheck source=../scripts/utils.sh
. scripts/utils.sh

PROGRAM=$(basename "${BASH_SOURCE[0]:-$0}")
VERSION=0.7.0

function display_help() {
cat <<EOF
$(help_title_section Usage)
${PROGRAM} [options]
$(help_title_section Options)
-h --help Show this screen.
-v --version Show version.
EOF
}

while [ ! $# -eq 0 ]; do
case "$1" in
-h | --help)
display_help
exit 0
;;
-v | --version)
display_version "${VERSION}" "${PROGRAM}"
exit 0
;;
*)
display_help >&2
exit 1
;;
esac

shift
done

source .venv/bin/activate

python3 -m bot
35 changes: 34 additions & 1 deletion bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,39 @@ cd "${BASE_DIR}/.." || exit 127
# shellcheck source=../scripts/utils.sh
. scripts/utils.sh

PROGRAM=$(basename "${BASH_SOURCE[0]:-$0}")
VERSION=0.7.0

function display_help() {
cat <<EOF
$(help_title_section Usage)
${PROGRAM} [options]
$(help_title_section Options)
-h --help Show this screen.
-v --version Show version.
EOF
}

while [ ! $# -eq 0 ]; do
case "$1" in
-h | --help)
display_help
exit 0
;;
-v | --version)
display_version "${VERSION}" "${PROGRAM}"
exit 0
;;
*)
display_help >&2
exit 1
;;
esac

shift
done

if not_installed "asdf"; then
echo_warning "
We are using asdf (https://github.com/asdf-vm/asdf) to manage tool
Expand All @@ -28,7 +61,7 @@ fi
log_info "setup" "Setting up the env file..."
if [ ! -f .env ]; then
cp .env.sample .env
log_done "env file created, you might want to open .env and set the correct values..."
log_success "env file created, you might want to open .env and set the correct values..."
echo
else
log_warn ".env file already exists, skipping..."
Expand Down
2 changes: 2 additions & 0 deletions scripts/colors.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/sh -n

RED=$(tput setaf 1)
ORANGE=$(tput setaf 3)
GREEN=$(tput setaf 2)
Expand Down
2 changes: 1 addition & 1 deletion scripts/extras.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,4 @@ function execute() {
return $exitCode
}

[ "$0" = "${BASH_SOURCE[0]}" ] && display_version 0.5.6 || true
[ "$0" = "${BASH_SOURCE[0]}" ] && display_version 0.7.0 || true
2 changes: 1 addition & 1 deletion scripts/fmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ function format() {
fi
}

[ "$0" = "${BASH_SOURCE[0]}" ] && display_version 0.5.6 || true
[ "$0" = "${BASH_SOURCE[0]}" ] && display_version 0.7.0 || true
2 changes: 1 addition & 1 deletion scripts/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ function help_title_section() {
echo -e "${BOLD}${TITLE}${RESET}"
}

[ "$0" = "${BASH_SOURCE[0]}" ] && display_version 0.5.6 || true
[ "$0" = "${BASH_SOURCE[0]}" ] && display_version 0.7.0 || true
2 changes: 1 addition & 1 deletion scripts/logging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ function log_info() {
__log "${LABEL}" "$CYAN" "$@"
}

[ "$0" = "${BASH_SOURCE[0]}" ] && display_version 0.5.6 || true
[ "$0" = "${BASH_SOURCE[0]}" ] && display_version 0.7.0 || true
9 changes: 7 additions & 2 deletions scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ function not_installed() {
function load_env_file() {
local file="${1:-.env}"
if [ -f "$file" ]; then
log_info "Environment" "Loading ${BLUE}${file}${RESET}..." $(cat "${file}")
log_info "Environment" "Loading ${BLUE}${file}${RESET}..." "$(cat "${file}")"
set -o allexport
# shellcheck source=/dev/null
source "$file"
set +o allexport
else
Expand Down Expand Up @@ -52,4 +53,8 @@ function ensure_confirmation() {
fi
}

[ "$0" = "${BASH_SOURCE[0]}" ] && display_version 0.5.6 || true
function get_os_name() {
uname | tr '[:upper:]' '[:lower:]'
}

[ "$0" = "${BASH_SOURCE[0]}" ] && display_version 0.7.0 || true

0 comments on commit 2a0d318

Please sign in to comment.