#[derive(Default, Clone)]
pub struct Flag {
pub(crate) is_global: bool,
pub(crate) name: String,
pub(crate) alias: Option<String>,
pub(crate) description: Option<String>,
}
pub struct PassedFlags {
pub map: std::collections::HashMap<String, String>,
}
impl PassedFlags {
pub fn get_flag_value(&self, name: &str) -> Option<&String> {
self.map.get(name)
}
pub fn contains_flag(&self, name: &str) -> bool {
self.map.contains_key(name)
}
pub fn iter(&self) -> impl Iterator<Item = (&String, &String)> {
self.map.iter()
}
}
impl Flag {
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
..Default::default()
}
}
pub fn global(name: impl Into<String>) -> Self {
Self {
is_global: true,
name: name.into(),
..Default::default()
}
}
pub fn alias(mut self, alias: impl Into<String>) -> Self {
self.alias = Some(alias.into());
self
}
pub fn description(mut self, desc: impl Into<String>) -> Self {
self.description = Some(desc.into());
self
}
}