Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/freebsd/poudriere.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/share
diff options
context:
space:
mode:
authorBryan Drewery <bryan@shatow.net>2022-09-15 21:54:08 +0300
committerBryan Drewery <bryan@shatow.net>2022-11-05 18:47:57 +0300
commitb9afffe13ff5826cb77a9624b07ef4d7c7349c6d (patch)
treed0f785560d8b13cc934172498e3237102dcce6e9 /src/share
parentffefb5706663204f56271bad77621022abfdd9cf (diff)
display: Support using column(1)
Diffstat (limited to 'src/share')
-rw-r--r--src/share/poudriere/include/display.sh28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/share/poudriere/include/display.sh b/src/share/poudriere/include/display.sh
index ff17c5f3..2ad18631 100644
--- a/src/share/poudriere/include/display.sh
+++ b/src/share/poudriere/include/display.sh
@@ -28,6 +28,7 @@ EX_DATAERR=65
EX_SOFTWARE=70
DISPLAY_SEP=$'\002'
+DISPLAY_USE_COLUMN=0
DISPLAY_DYNAMIC_FORMAT_DEFAULT="%%-%ds"
DISPLAY_TRIM_TRAILING_FIELD=1
@@ -51,6 +52,13 @@ display_setup() {
unset IFS
}
+_display_cleanup() {
+ unset _DISPLAY_DATA _DISPLAY_FORMAT \
+ _DISPLAY_COLUMN_SORT \
+ _DISPLAY_LINES _DISPLAY_COLS \
+ _DISPLAY_FOOTER _DISPLAY_HEADER
+}
+
display_add() {
[ $# -gt 0 ] || eargs display_add col [col...]
local IFS
@@ -213,6 +221,20 @@ display_output() {
sort -t "${DISPLAY_SEP}" ${_DISPLAY_COLUMN_SORT})"
fi
+ if [ "${DISPLAY_USE_COLUMN}" -eq 1 ]; then
+ {
+ if [ "${quiet}" -eq 0 ]; then
+ echo "${_DISPLAY_HEADER}"
+ fi
+ echo "${_DISPLAY_DATA}"
+ if [ -n "${_DISPLAY_FOOTER}" ]; then
+ echo "${_DISPLAY_FOOTER}"
+ fi
+ } | column -t -s "${DISPLAY_SEP}"
+ _display_cleanup
+ return
+ fi
+
# Determine optimal format from filtered data
_display_check_lengths "${_DISPLAY_HEADER}"
_display_check_lengths "${_DISPLAY_FOOTER}"
@@ -292,9 +314,5 @@ display_output() {
unset IFS
printf "${format}\n" "$@"
fi
-
- unset _DISPLAY_DATA _DISPLAY_FORMAT \
- _DISPLAY_COLUMN_SORT \
- _DISPLAY_LINES _DISPLAY_COLS \
- _DISPLAY_FOOTER _DISPLAY_HEADER
+ _display_cleanup
}