#!/bin/bash

. $(ffoom path)

ffoo import pretty
ffoo import types

mkbrief() {
    local line ifno maybe_ifno ifname ipinfo
    while read line;
    do
        maybe_ifno=${line%%:*}
        debug -v maybe_ifno
        if is_integer "$maybe_ifno";
        then
            ifno=$maybe_ifno
            ifname=${line##$ifno: }
            ifname=${ifname%%:*}
            debug -v ifno ifname
        elif grep -qs '^inet ' <<<"$line";
        then
            ipv4=${line##inet }
            ipv4=${ipv4%% *}
            debug -v ipv4
            printf "%-7s %s\n" $ifname $ipv4
        fi
    done
}

ip addr show | mkbrief