use crate::config::ResolvedServer;
use anyhow::{Result, anyhow};
#[path = "target.rs"]
mod target;
pub(crate) use target::group_suffix_matches;
pub use target::{
WallixMenuEntry, build_expected_groups, build_expected_target, build_expected_targets,
};
#[path = "menu.rs"]
mod menu;
pub use menu::parse_wallix_menu;
#[path = "select.rs"]
mod select;
pub use select::{select_id_by_target_and_group, select_id_for_server};
pub(crate) fn strip_ansi(input: &str) -> String {
let mut out = String::with_capacity(input.len());
let mut chars = input.chars().peekable();
while let Some(ch) = chars.next() {
if ch == '\x1b' {
match chars.peek() {
Some('[') => {
chars.next();
for c in chars.by_ref() {
if c.is_ascii_alphabetic() {
break;
}
}
}
Some('(') | Some(')') | Some('*') | Some('+') => {
chars.next();
chars.next(); }
_ => {
chars.next(); }
}
} else {
out.push(ch);
}
}
out
}
#[cfg(test)]
#[path = "tests.rs"]
mod tests;