#!/bin/bash
# SPDX-Version: 3.0
# SPDX-CreationInfo: 2025-06-17; WEIDNER, Marc S.; <msw@coresecret.dev>
# SPDX-ExternalRef: GIT https://git.coresecret.dev/msw/CISS.debian.installer.git
# SPDX-FileContributor: WEIDNER, Marc S.; Centurion Intelligence Consulting Agency
# SPDX-FileCopyrightText: 2024-2025; WEIDNER, Marc S.; <msw@coresecret.dev>
# SPDX-FileType: SOURCE
# SPDX-License-Identifier: EUPL-1.2 OR LicenseRef-CCLA-1.0
# SPDX-LicenseComment: This file is part of the CISS.debian.installer.secure framework.
# SPDX-PackageName: CISS.debian.installer
# SPDX-Security-Contact: security@coresecret.eu

guard_sourcing

#######################################
# Wrapper around 'printf' for clean code.
# Globals:
#   C_RES
# Arguments:
#   1: One of "${C_BLA}" | "${C_RED}" | "${C_GRE}" | "${C_YEL}" | "${C_BLU}" | "${C_MAG}" | "${C_CYA}" | "${C_WHI}"
#   2: Text string to print on terminal.
#######################################
do_print_color() {
  printf "%s\n" "${1}${2}${C_RES}"
}

#######################################
# Wrapper around 'printf' for clean, uniform terminal output and line fold for long text strings for better readability.
# Globals:
#   C_RES
# Arguments:
#   1: One of "${C_BLA}" | "${C_RED}" | "${C_GRE}" | "${C_YEL}" | "${C_BLU}" | "${C_MAG}" | "${C_CYA}" | "${C_WHI}"
#   2: Text string to print on terminal.
#######################################
do_print_fold() {
  declare var_color="$1"; shift
  declare var_msg_string="$*"
  declare var_formatted_string="${var_color}${var_msg_string}${C_RES}"
  printf "%b\n" "${var_formatted_string}" | fold -s -w 76 | sed '1! s/^/    /'
}

#######################################
# Wrapper around 'printf' for logfile redirect.
# Arguments:
#   1: Text string to redirect to a log file.
#######################################
do_print_log() {
  printf "%s\n" "${1}"
}
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
