Skip to content

Commit 0841780

Browse files
committed
Fix console indentation and unify progress box widths across installation scripts
1 parent 834ed1e commit 0841780

4 files changed

Lines changed: 56 additions & 36 deletions

File tree

scripts/lib/error_tracking.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ try_step() {
221221
# Print captured output to help debug failures
222222
if [[ -n "$LAST_ERROR_OUTPUT" ]]; then
223223
echo " Error output:" >&2
224-
echo "$LAST_ERROR_OUTPUT" | head -50 | sed 's/^/ /' >&2
224+
echo "$LAST_ERROR_OUTPUT" | head -50 | sed 's/^/ /' >&2
225225
fi
226226
fi
227227

scripts/lib/logging.sh

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ fi
123123
# Usage: log_detail "Installing zsh..."
124124
if ! declare -f log_detail >/dev/null; then
125125
log_detail() {
126-
printf "${ACFS_GRAY} %s${ACFS_NC}\n" "$1" >&2
126+
# Indent every line of the message with 2 spaces
127+
echo -e "$1" | sed "s/^/${ACFS_GRAY} /" | sed "s/$/${ACFS_NC}/" >&2
127128
}
128129
fi
129130

@@ -139,23 +140,23 @@ fi
139140
# Usage: log_success "Installation complete"
140141
if ! declare -f log_success >/dev/null; then
141142
log_success() {
142-
printf "${ACFS_GREEN}%s${ACFS_NC}\n" "$1" >&2
143+
echo -e "$1" | sed "1s/^/${ACFS_GREEN}/; 1!s/^/ /; s/$/${ACFS_NC}/" >&2
143144
}
144145
fi
145146

146147
# Log warning message (yellow with warning symbol)
147148
# Usage: log_warn "This may take a while"
148149
if ! declare -f log_warn >/dev/null; then
149150
log_warn() {
150-
printf "${ACFS_YELLOW}%s${ACFS_NC}\n" "$1" >&2
151+
echo -e "$1" | sed "1s/^/${ACFS_YELLOW}/; 1!s/^/ /; s/$/${ACFS_NC}/" >&2
151152
}
152153
fi
153154

154155
# Log error message (red with X)
155156
# Usage: log_error "Failed to install package"
156157
if ! declare -f log_error >/dev/null; then
157158
log_error() {
158-
printf "${ACFS_RED}%s${ACFS_NC}\n" "$1" >&2
159+
echo -e "$1" | sed "1s/^/${ACFS_RED}/; 1!s/^/ /; s/$/${ACFS_NC}/" >&2
159160
}
160161
fi
161162

@@ -253,8 +254,18 @@ if ! declare -f show_progress_header >/dev/null; then
253254

254255
echo -e "║ Progress: [${bar}]${prog_detail}${padding}" >&2
255256
printf "║ Current: %-50s ║\n" "$display_name" >&2
256-
printf "║ Elapsed: %3dm %02ds ║\n" \
257-
"$elapsed_min" "$elapsed_sec" >&2
257+
258+
# Calculate elapsed line with dynamic padding
259+
local elapsed_str
260+
printf -v elapsed_str " Elapsed: %dm %02ds" "$elapsed_min" "$elapsed_sec"
261+
local elapsed_len=${#elapsed_str}
262+
local el_pad_len=$((63 - elapsed_len))
263+
local el_padding=""
264+
if [[ $el_pad_len -gt 0 ]]; then
265+
el_padding=$(printf "%${el_pad_len}s" "")
266+
fi
267+
echo -e "${elapsed_str}${el_padding}" >&2
268+
258269
echo "╚═══════════════════════════════════════════════════════════════╝" >&2
259270
echo "" >&2
260271
}
@@ -273,7 +284,16 @@ if ! declare -f show_completion >/dev/null; then
273284
echo "╔═══════════════════════════════════════════════════════════════╗" >&2
274285
echo "║ ✓ Installation Complete! ║" >&2
275286
echo "╠═══════════════════════════════════════════════════════════════╣" >&2
276-
printf "║ Total time: %3dm %02ds ║\n" "$min" "$sec" >&2
287+
288+
local timer_str
289+
printf -v timer_str " Total time: %dm %02ds" "$min" "$sec"
290+
local timer_len=${#timer_str}
291+
local t_pad_len=$((63 - timer_len))
292+
local t_padding=""
293+
if [[ $t_pad_len -gt 0 ]]; then
294+
t_padding=$(printf "%${t_pad_len}s" "")
295+
fi
296+
echo -e "${timer_str}${t_padding}" >&2
277297

278298
# Dynamic padding for "Phases completed: X/Y"
279299
# Label " Phases completed: " is 20 chars.

scripts/lib/sandbox.sh

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ ACFS_PROFILE_NAME="acfs-local-profile"
2828
# Logging (fallbacks if not sourced from install.sh)
2929
# ============================================================
3030
if ! declare -f log_detail &>/dev/null; then
31-
log_detail() { printf " → %s\n" "$1" >&2; }
32-
log_success() { printf "✓ %s\n" "$1" >&2; }
33-
log_warn() { printf "⚠ %s\n" "$1" >&2; }
34-
log_error() { printf "✖ %s\n" "$1" >&2; }
35-
log_fatal() { printf "FATAL: %s\n" "$1" >&2; exit 1; }
31+
log_detail() { echo -e "$1" | sed "s/^/ /" >&2; }
32+
log_success() { echo -e "$1" | sed "1s/^/✓ /; 1!s/^/ /" >&2; }
33+
log_warn() { echo -e "$1" | sed "1s/^/⚠ /; 1!s/^/ /" >&2; }
34+
log_error() { echo -e "$1" | sed "1s/^/✖ /; 1!s/^/ /" >&2; }
35+
log_fatal() { log_error "$1"; exit 1; }
3636
log_step() { printf "[%s] %s\n" "$1" "$2" >&2; }
3737
fi
3838

@@ -186,11 +186,11 @@ grant_acfs_sandbox_access() {
186186

187187
log_detail "Attempting automated group refresh..."
188188
echo ""
189-
echo "╔══════════════════════════════════════════════════════════════╗"
190-
echo "║ Refreshing Group Permissions (Autoswitching) ║"
191-
echo "╠══════════════════════════════════════════════════════════════╣"
192-
echo "║ Restarting installer with 'lxd' group enabled... ║"
193-
echo "╚══════════════════════════════════════════════════════════════╝"
189+
echo "╔══════════════════════════════════════════════════════════════"
190+
echo "║ Refreshing Group Permissions (Autoswitching) "
191+
echo "╠══════════════════════════════════════════════════════════════"
192+
echo "║ Restarting installer with 'lxd' group enabled... "
193+
echo "╚══════════════════════════════════════════════════════════════"
194194
echo ""
195195

196196
# Restart the script with the new group
@@ -496,24 +496,24 @@ acfs_sandbox_status() {
496496
grant_acfs_sandbox_access
497497

498498
if ! acfs_sandbox_exists; then
499-
echo "Status: Not created"
499+
log_detail "Status: Not created"
500500
echo ""
501-
echo "Create with: acfs-local create"
501+
log_detail "Create with: acfs-local create"
502502
return 0
503503
fi
504504

505505
local state ip
506506
state=$(acfs_lxc info "$ACFS_CONTAINER_NAME" 2>/dev/null | grep -E "^Status:" | awk '{print $2}')
507507

508-
echo "Container: $ACFS_CONTAINER_NAME"
509-
echo "Status: $state"
508+
log_detail "Container: $ACFS_CONTAINER_NAME"
509+
log_detail "Status: $state"
510510

511511
if [[ "$state" == "RUNNING" ]]; then
512512
ip=$(acfs_lxc info "$ACFS_CONTAINER_NAME" 2>/dev/null | grep -A1 "eth0:" | grep "inet:" | awk '{print $2}' | cut -d/ -f1 | head -1)
513-
echo "IP: ${ip:-unknown}"
514-
echo "Dashboard: http://localhost:$ACFS_DASHBOARD_PORT"
515-
echo "Workspace (host): $ACFS_WORKSPACE_HOST"
516-
echo "Workspace (container): $ACFS_WORKSPACE_CONTAINER"
513+
log_detail "IP: ${ip:-unknown}"
514+
log_detail "Dashboard: http://localhost:$ACFS_DASHBOARD_PORT"
515+
log_detail "Workspace (host): $ACFS_WORKSPACE_HOST"
516+
log_detail "Workspace (container): $ACFS_WORKSPACE_CONTAINER"
517517
fi
518518
}
519519

scripts/local/acfs_container.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ EOF
6565

6666
cmd_create() {
6767
echo ""
68-
echo "╔══════════════════════════════════════════════════════════════╗"
69-
echo "║ ACFS Local Desktop Installation "
70-
echo "╚══════════════════════════════════════════════════════════════╝"
68+
echo "╔══════════════════════════════════════════════════════════════"
69+
printf "║ ACFS Local Desktop Installation ║\n"
70+
echo "╚══════════════════════════════════════════════════════════════"
7171
echo ""
7272

7373
install_acfs_local_wrapper
@@ -97,17 +97,17 @@ cmd_create() {
9797
"
9898

9999
echo ""
100-
echo "╔══════════════════════════════════════════════════════════════╗"
100+
echo "╔══════════════════════════════════════════════════════════════"
101101
echo "║ Installation Complete! ║"
102-
echo "╠══════════════════════════════════════════════════════════════╣"
102+
echo "╠══════════════════════════════════════════════════════════════"
103103
echo "║ ║"
104-
echo "║ Enter sandbox: acfs-local shell ║"
105-
echo "║ View status: acfs-local status ║"
106-
echo "║ Open dashboard: acfs-local dashboard ║"
104+
echo "║ Enter sandbox: acfs-local shell "
105+
echo "║ View status: acfs-local status "
106+
echo "║ Open dashboard: acfs-local dashboard "
107107
echo "║ ║"
108-
echo "║ Your workspace: $ACFS_WORKSPACE_HOST"
108+
printf "║ Your workspace: %-41s ║\n" "$ACFS_WORKSPACE_HOST"
109109
echo "║ ║"
110-
echo "╚══════════════════════════════════════════════════════════════╝"
110+
echo "╚══════════════════════════════════════════════════════════════"
111111
echo ""
112112
}
113113

0 commit comments

Comments
 (0)