auraline 0.5.3

utility that renders information into a string suitable to be embedded in the shell prompt.
1
2
3
4
5
6
7
8
9
10
11
12
13
use std::collections::BTreeSet;
use itertools::Itertools;

use crate::options::Options;

pub async fn show(_: &Options) -> Option<String> {
    let ifaddrs = if_addrs::get_if_addrs().ok()?;
    let uniq : BTreeSet<String> = ifaddrs.iter().filter_map(|ni|
        matches!(ni.oper_status, if_addrs::IfOperStatus::Up).then_some(ni.name.to_owned())
    ).collect::<BTreeSet<_>>();
    let names: Vec<&String> = uniq.iter().collect();
    Some(names.iter().copied().join(","))
}