From fdf027d2828cb697080568eec3358c4985a3a432 Mon Sep 17 00:00:00 2001 From: Richard Alpe Date: Mon, 21 Aug 2023 10:10:21 +0200 Subject: [PATCH] cli: change header design in show interfaces Signed-off-by: Richard Alpe --- board/netconf/rootfs/lib/infix/json-cfg-pretty | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/board/netconf/rootfs/lib/infix/json-cfg-pretty b/board/netconf/rootfs/lib/infix/json-cfg-pretty index fbd531ba..78d718bf 100755 --- a/board/netconf/rootfs/lib/infix/json-cfg-pretty +++ b/board/netconf/rootfs/lib/infix/json-cfg-pretty @@ -5,6 +5,11 @@ RED='\033[0;31m' GREEN='\033[0;32m' NC='\033[0m' # No Color +GREY_BG="\e[48;5;235m" +RESET="\e[0m" + +HEADER_WIDHT=80 + usage() { printf "Please provide a valid base field as the first argument\n" exit 1 @@ -63,7 +68,12 @@ show_ietf_interfaces() { interfaces=$(echo "$json" | jq -c --arg field "$field" '.[$field].interface[]') - printf "${CYAN}%-15s %-15s %-18s %s${NC}\n" "NAME" "STATE" "MAC" "IPv4" + HEADER=$(printf "%-15s %-15s %-18s %s\n" "NAME" "STATE" "MAC" "IPv4") + HEADER_LEN=${#HEADER} + RIGHT_PADDING=$(( HEADER_WIDHT - HEADER_LEN )) + + printf "${GREY_BG}%s%${RIGHT_PADDING}s${RESET}\n" "$HEADER" "" + for iface in $interfaces; do name="$(echo "$iface" | jq -r '.["name"]')" state="$(echo "$iface" | jq -r '.["oper-status"]')"