Support column(1) from bsdmainutils

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
This commit is contained in:
Andre Moreira Magalhaes 2019-04-26 15:01:27 -03:00 committed by Debarshi Ray
parent 1a69573575
commit e6389a9ef1

31
toolbox
View file

@ -506,6 +506,7 @@ images_get_details()
echo "$base_toolbox_command: failed to get details for image $image" >&2 echo "$base_toolbox_command: failed to get details for image $image" >&2
return 1 return 1
fi fi
echo
done; then done; then
return 1 return 1
fi fi
@ -1047,6 +1048,8 @@ run()
list_images() list_images()
( (
output=""
if ! images_old=$($prefix_sudo podman images \ if ! images_old=$($prefix_sudo podman images \
--filter "label=com.redhat.component=fedora-toolbox" \ --filter "label=com.redhat.component=fedora-toolbox" \
--format "{{.Repository}}:{{.Tag}}" 2>&3); then --format "{{.Repository}}:{{.Tag}}" 2>&3); then
@ -1066,11 +1069,12 @@ list_images()
return 1 return 1
fi fi
if ! output=$(echo "$details" \ if [ "$details" != "" ] 2>&3; then
| sed "s/ \{2,\}/\t/g" 2>&3 \ table_data=$(printf "%s\t%s\t%s\n" "IMAGE ID" "IMAGE NAME" "CREATED"; echo "$details")
| column --separator "$tab" --table --table-columns "IMAGE ID,IMAGE NAME,CREATED" 2>&3); then 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 echo "$base_toolbox_command: failed to parse list of images" >&2
return 1 return 1
fi
fi fi
if [ "$output" != "" ]; then if [ "$output" != "" ]; then
@ -1106,6 +1110,8 @@ containers_get_details()
list_containers() list_containers()
( (
output=""
if ! containers=$(list_container_names); then if ! containers=$(list_container_names); then
return 1 return 1
fi fi
@ -1114,14 +1120,13 @@ list_containers()
return 1 return 1
fi fi
if ! output=$(echo "$details" \ if [ "$details" != "" ] 2>&3; then
| sed "s/ \{2,\}/\t/g" 2>&3 \ table_data=$(printf "%s\t%s\t%s\t%s\t%s\n" "CONTAINER ID" "CONTAINER NAME" "CREATED" "STATUS" "IMAGE NAME"
| column \ echo "$details")
--separator "$tab" \ if ! output=$(echo "$table_data" | sed "s/ \{2,\}/\t/g" 2>&3 | column -s "$tab" -t 2>&3); then
--table \ echo "$base_toolbox_command: failed to parse list of containers" >&2
--table-columns "CONTAINER ID,CONTAINER NAME,CREATED,STATUS,IMAGE NAME" 2>&3); then return 1
echo "$base_toolbox_command: failed to parse list of containers" >&2 fi
return 1
fi fi
if [ "$output" != "" ]; then if [ "$output" != "" ]; then