use std::convert::Infallible; use clap::Args; use crate::{session::SessionWriter, Session}; #[derive(Debug, Clone, Args)] #[group(skip)] pub struct Config { /// Exclude item from output #[arg(short, long)] pub exclude: Vec, } impl Config { pub fn new(Config { exclude }: Config) -> Self { Self { exclude } } } pub struct Stdout { exclude: Vec, } impl Stdout { pub fn new(Config { exclude }: Config) -> Self { Self { exclude } } } impl SessionWriter for Stdout { type Writer = std::io::Stdout; type Error = Infallible; fn format(&self, session: &Session) -> Result { Ok(session.name.to_string()) } fn filter(&self, session: &Session) -> bool { !self.exclude.contains(&session.name) } fn writer(&self) -> Result { Ok(std::io::stdout()) } }