yogurt/argument/mod.rs
1pub mod parser;
2
3pub struct Argument {
4 validator: fn(&str) -> bool,
5 pub name: String,
6 required: bool,
7}
8
9impl Argument {
10 pub fn new(validator: fn(&str) -> bool, name: String, required: bool) -> Self {
11 Self {
12 validator,
13 name,
14 required,
15 }
16 }
17
18 pub fn matches(&self, sample: &str) -> bool {
19 (self.validator)(sample)
20 }
21
22 pub fn is_required(&self) -> bool {
23 self.required
24 }
25}