Return more error codes as return value of exe.

This commit is contained in:
Your Name
2025-05-05 22:19:04 +12:00
parent 9d01554b13
commit ac20fcec3d
10 changed files with 99 additions and 74 deletions

View File

@ -1,23 +1,49 @@
#!/bin/bash
# default config should always work for localhost
SCRIPT_DIR=$(dirname "$0")
TEMPLATE="$1"
# make sure TEMPLATE doesn't end with a /
TEMPLATE=$(basename "$TEMPLATE")
# default config should always work for localhost
function die() {
echo "$1"
exit 1
}
function title() {
echo "----------------------------------------"
echo "$1"
echo "----------------------------------------"
function dashes() {
for ((i=0; i<$1; i++)); do
echo -n "-"
done
echo ""
}
function centerprint() {
# print $1 centered
local width=$2
local padding=$(( (width - ${#1}) / 2 ))
for ((i=0; i<$padding; i++)); do
echo -n " "
done
echo "$1"
}
function title() {
# determine terminal width
TERMINAL_WIDTH=$(tput cols)
echo " "
dashes $TERMINAL_WIDTH
centerprint "$1" $TERMINAL_WIDTH
dashes $TERMINAL_WIDTH
}
# do we have the first argument?
if [ -z "$1" ]; then
echo "Usage: $0 <template>"
exit 1
fi
TEMPLATE=$(basename "$1")
if [ ! -d "$SCRIPT_DIR/$TEMPLATE" ]; then
echo "Local Template $TEMPLATE does not exist"
exit 1
@ -60,4 +86,8 @@ title "Listing services"
ds list localhost || die "Failed to list services"
# change to green font
echo -e "\033[32m"
title "ALL TESTS PASSED FOR $TEMPLATE"
echo -e "\033[0m"
echo " "