Skip to content

Commit

Permalink
update lib
Browse files Browse the repository at this point in the history
  • Loading branch information
gdbtek committed Apr 8, 2019
1 parent 5b7043a commit ada8817
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions libraries/util.bash
Original file line number Diff line number Diff line change
Expand Up @@ -1777,10 +1777,12 @@ function printTable()
{
local -r delimiter="${1}"
local -r tableData="$(removeEmptyLines "${2}")"
local -r colorHeader="${3}"
local -r displayTotalCount="${4}"

if [[ "${delimiter}" != '' && "$(isEmptyString "${tableData}")" = 'false' ]]
then
local -r numberOfLines="$(wc -l <<< "${tableData}")"
local -r numberOfLines="$(trimString "$(wc -l <<< "${tableData}")")"

if [[ "${numberOfLines}" -gt '0' ]]
then
Expand Down Expand Up @@ -1825,9 +1827,22 @@ function printTable()

if [[ "$(isEmptyString "${table}")" = 'false' ]]
then
echo -e "${table}" | column -s '#' -t | awk '/^\+/{gsub(" ", "-", $0)}1'
local output="$(echo -e "${table}" | column -s '#' -t | awk '/^\+/{gsub(" ", "-", $0)}1')"

if [[ "${colorHeader}" = 'true' ]]
then
echo -e "\033[1;32m$(head -n 3 <<< "${output}")\033[0m"
tail -n +4 <<< "${output}"
else
echo "${output}"
fi
fi
fi

if [[ "${displayTotalCount}" = 'true' && "${numberOfLines}" -ge '0' ]]
then
echo -e "\n\033[1;36mTOTAL ROWS : $((numberOfLines - 1))\033[0m"
fi
fi
}

Expand Down

0 comments on commit ada8817

Please sign in to comment.