Adds bootstrap.v2

This commit is contained in:
Michel Fedde 2025-04-21 22:19:46 +02:00
parent 06c8003cf2
commit 2bbccb4595
61 changed files with 468 additions and 4 deletions

View file

@ -0,0 +1,74 @@
#!/bin/env sh
_repeat() {
local start=1
local end=${1:-80}
local str="${2:-=}"
local range=$(seq $start $end)
for i in $range; do echo -n "${str}"; done
}
_header() {
local length="$1"
echo -n "/="
_repeat ${length} "="
echo "=\\"
}
_value() {
local value="$1"
echo -n "| "
echo -n ${value}
echo " |"
}
_footer() {
local length="$1"
echo -n "\\="
_repeat ${length} "="
echo "=/"
}
display() {
local value="$1"
_header ${#value}
_value "${value}"
_footer ${#value}
}
runfile() {
local command="$1"
local commandName=$(basename $command)
local prompt="Do you wish to run $commandName? [Ynq]"
local display="Executing $commandName"
local promptLength=$((${#prompt}))
local displayLength=${#display}
local maxWidth=$((promptLength > displayLength ? promptLength : displayLength))
_header ${maxWidth}
read -p "| $prompt |" -n 1 -r -s
echo
if [[ $REPLY =~ ^[Nn]$ ]]; then
_footer ${maxWidth}
return
fi
if [[ $REPLY =~ ^[Qq]$ ]]; then
_footer ${maxWidth}
display "Exiting..."
exit 0
fi
echo -n "| $display"
_repeat $((maxWidth - displayLength)) " "
echo " |"
_footer ${maxWidth}
if ! "$command"; then
echo "Error: bootstrap '$command' failed" >&2
exit 1
fi
}