use crate::opt::{ActiveOpt, OptKind}; #[derive(Debug)] pub struct Context { opts: Vec, } impl Context { pub(crate) fn new(opts: Vec) -> Self { Self { opts } } pub fn flag(&self, name: &str) -> bool { self.opts .iter() .any(|o| o.definition.name == name && matches!(o.definition.kind, OptKind::Flag)) } pub fn get_string(&self, name: &str) -> Option { self.opts .iter() .find_map(|o| { if o.definition.name == name { Some(o.raw_value.first().cloned()) } else { None } }) .flatten() } }