Skip to content

Commit

Permalink
Support column(1) from bsdmainutils
Browse files Browse the repository at this point in the history
Fedora ships with column(1) from util-linux [1], which supports the
--table-columns option and long option names that are missing in
Debian's column(1) from bsdmainutils [2].

[1] http://man7.org/linux/man-pages/man1/column.1.html
[2] https://manpages.debian.org/testing/bsdmainutils/column.1.en.html

https://github.com/debarshiray/toolbox/pull/137
  • Loading branch information
andrunko authored and debarshiray committed May 21, 2019
1 parent 1a69573 commit e6389a9
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions toolbox
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ images_get_details()
echo "$base_toolbox_command: failed to get details for image $image" >&2
return 1
fi
echo
done; then
return 1
fi
Expand Down Expand Up @@ -1047,6 +1048,8 @@ run()

list_images()
(
output=""

if ! images_old=$($prefix_sudo podman images \
--filter "label=com.redhat.component=fedora-toolbox" \
--format "{{.Repository}}:{{.Tag}}" 2>&3); then
Expand All @@ -1066,11 +1069,12 @@ list_images()
return 1
fi

if ! output=$(echo "$details" \
| sed "s/ \{2,\}/\t/g" 2>&3 \
| column --separator "$tab" --table --table-columns "IMAGE ID,IMAGE NAME,CREATED" 2>&3); then
echo "$base_toolbox_command: failed to parse list of images" >&2
return 1
if [ "$details" != "" ] 2>&3; then
table_data=$(printf "%s\t%s\t%s\n" "IMAGE ID" "IMAGE NAME" "CREATED"; echo "$details")
if ! output=$(echo "$table_data" | sed "s/ \{2,\}/\t/g" 2>&3 | column -s "$tab" -t 2>&3); then
echo "$base_toolbox_command: failed to parse list of images" >&2
return 1
fi
fi

if [ "$output" != "" ]; then
Expand Down Expand Up @@ -1106,6 +1110,8 @@ containers_get_details()

list_containers()
(
output=""

if ! containers=$(list_container_names); then
return 1
fi
Expand All @@ -1114,14 +1120,13 @@ list_containers()
return 1
fi

if ! output=$(echo "$details" \
| sed "s/ \{2,\}/\t/g" 2>&3 \
| column \
--separator "$tab" \
--table \
--table-columns "CONTAINER ID,CONTAINER NAME,CREATED,STATUS,IMAGE NAME" 2>&3); then
echo "$base_toolbox_command: failed to parse list of containers" >&2
return 1
if [ "$details" != "" ] 2>&3; then
table_data=$(printf "%s\t%s\t%s\t%s\t%s\n" "CONTAINER ID" "CONTAINER NAME" "CREATED" "STATUS" "IMAGE NAME"
echo "$details")
if ! output=$(echo "$table_data" | sed "s/ \{2,\}/\t/g" 2>&3 | column -s "$tab" -t 2>&3); then
echo "$base_toolbox_command: failed to parse list of containers" >&2
return 1
fi
fi

if [ "$output" != "" ]; then
Expand Down

0 comments on commit e6389a9

Please sign in to comment.