diff --git a/readme.md b/readme.md index 08f857f..8e85647 100644 --- a/readme.md +++ b/readme.md @@ -213,8 +213,8 @@ Handle project workflows in a unified way: ### Shell +* banner with constants for characters * comment -* fit banner to text * review repositories handling for systems * opensuse * codecs repository diff --git a/spcd/main.sh b/spcd/main.sh index 1e7f9d2..4042412 100644 --- a/spcd/main.sh +++ b/spcd/main.sh @@ -828,10 +828,38 @@ ${SPCD_PYTHON_ALIAS} / ${spcd_stp__name}" # functions spcd_banner() { - echo "\ -${SPCD_DOWN} -${SPCD_VERT} ${*} -${SPCD___UP}" + unset SPCD_BANNER_1 SPCD_BANNER_2 SPCD_BANNER_3 + spcd_banner_add_123 "${SPCD_DOWN}" "${SPCD_VERT}" "${SPCD___UP}" + # + spcd_banner__index="${SPCD_STEP}" + [ -n "${SPCD_SUBSTEP}" ] && + spcd_banner__index="${spcd_banner__index}.${SPCD_SUBSTEP}" + spcd_banner_add "${spcd_banner__index}" + # + for spcd_banner__item in "${SPCD_STEP_TEXT}" "${SPCD_SUBSTEP_TEXT}"; do + spcd_banner_add_123 "┬" "${SPCD_VERT}" "┴" + spcd_banner_add "${spcd_banner__item}" + done + # + spcd_banner_add_123 "╮" "${SPCD_VERT}" "╯" +} + +spcd_banner_add() { + if [ -n "${1}" ]; then + spcd_ba__text=" ${1} " + spcd_ba__length=${#spcd_ba__text} + spcd_ba__filler="$(spcd_fill "${spcd_ba__length}" ─)" + spcd_banner_add_123 \ + "${spcd_ba__filler}" "${spcd_ba__text}" "${spcd_ba__filler}" + fi +} + +spcd_banner_add_123() { + if [ -n "${3}" ]; then + SPCD_BANNER_1="${SPCD_BANNER_1}${1}" + SPCD_BANNER_2="${SPCD_BANNER_2}${2}" + SPCD_BANNER_3="${SPCD_BANNER_3}${3}" + fi } spcd_cat() { @@ -865,14 +893,20 @@ spcd_error_os() { exit "${SPCD_ERROR_OS}" } +spcd_fill() { + spcd_fill__index=${1} + while [ "${spcd_fill__index}" -gt 0 ]; do + printf "%s" "${2}" + spcd_fill__index=$((spcd_fill__index - 1)) + done +} + spcd_git_clone() { if [ -n "${1}" ]; then spcd_gc__name="$(basename "${1}")" spcd_gc__path="${SPCD_DL}/${spcd_gc__name}" spcd_gc__url="$(spcd_git_url "${1}")" - git clone \ - "${spcd_gc__url}" \ - "${spcd_gc__path}" + git clone "${spcd_gc__url}" "${spcd_gc__path}" echo "${spcd_gc__path}" fi } @@ -985,18 +1019,14 @@ spcd_split() { spcd_step() { SPCD_STEP=$((SPCD_STEP + 1)) SPCD_STEP_TEXT="${*}" - unset SPCD_SUBSTEP - spcd_banner "${SPCD_STEP}" "${SPCD_VERT}" "${SPCD_STEP_TEXT}" + unset SPCD_SUBSTEP SPCD_SUBSTEP_TEXT + spcd_banner } spcd_substep() { SPCD_SUBSTEP=$((SPCD_SUBSTEP + 1)) - spcd_banner \ - "${SPCD_STEP}.${SPCD_SUBSTEP}" \ - "${SPCD_VERT}" \ - "${SPCD_STEP_TEXT}" \ - "${SPCD_VERT}" \ - "${*}" + SPCD_SUBSTEP_TEXT="${*}" + spcd_banner } spcd_write() {