refactor: Standardize output with printf and introduce die helper

This commit is contained in:
Matteo Cherubini 2026-05-09 17:03:15 +02:00
parent d69b7622a3
commit ddd86fd5d5
2 changed files with 9 additions and 8 deletions

View file

@ -154,7 +154,7 @@ gcrypt_print_key_instructions() {
local genome_name="$1"
local v_url="${VAULTWARDEN_URL:-https://your-vaultwarden.com}"
echo -e "\n ── ${BOLD}Key Management: ${genome_name}${NC} ──\n"
printf "\n ── %b ──\n\n" "${BOLD}Key Management: ${genome_name}${NC}"
echo " 1. Encode the key to base64:"
echo " base64 < ${KEYS_DIR}/${genome_name}.key"
echo ""

View file

@ -15,11 +15,12 @@ else
GREEN='' YELLOW='' CYAN='' RED='' BOLD='' NC=''
fi
info() { echo -e "${CYAN}[INFO]${NC} $*"; }
success() { echo -e "${GREEN}[OK]${NC} $*"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
error() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
step() { echo -e "\n${BOLD}${YELLOW}━━━ $* ━━━${NC}"; }
info() { printf "%b\n" "${CYAN}[INFO]${NC} $*"; }
success() { printf "%b\n" "${GREEN}[OK]${NC} $*"; }
warn() { printf "%b\n" "${YELLOW}[WARN]${NC} $*"; }
error() { printf "%b\n" "${RED}[ERROR]${NC} $*" >&2; }
die() { error "$*"; exit 1; }
step() { printf "\n%b\n" "${BOLD}${YELLOW}━━━ $* ━━━${NC}"; }
box() {
local max_len=0
@ -28,9 +29,9 @@ box() {
done
local border
border=$(printf '─%.0s' $(seq 1 $((max_len + 2))))
echo -e "${CYAN}${border}${NC}"
printf "%b\n" "${CYAN}${border}${NC}"
for line in "$@"; do
printf "${CYAN}${NC} %-${max_len}s ${CYAN}${NC}\n" "$line"
done
echo -e "${CYAN}${border}${NC}"
printf "%b\n" "${CYAN}${border}${NC}"
}