1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
/// # Type
/// types for flag
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Type {
Command,
Config,
Error,
}
/// # Flag
///
/// Flag struct describe each **individual** flag
/// composed by:
/// - __order__ : usize -> order of the flag
/// - __flag__ : String -> value of flag
/// - __type__ : Type -> type of flag
///
#[derive(Debug, Clone)]
pub struct Flag {
pub value: String,
pub flag_type: Type,
}
impl Flag {
/// # new flag
///
/// Create a new flag with order
///
/// ## Params
/// - **order**: usize
/// - **args**: &mut Args
///
pub fn new(arg: String) -> Self {
Self {
value: arg.clone(),
flag_type: if arg.starts_with('-') {
Type::Config
} else {
Type::Command
},
}
}
}