blob: c3a0affe7c50fe6611359ce2162d8732f690b9bf (
plain)
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
|
use std::cell::RefCell;
use std::rc::Rc;
pub enum ParseResult {
Parsed,
Help,
Exit,
Error(String),
}
pub enum Action<'a> {
Flag(Box<IFlagAction + 'a>),
Single(Box<IArgAction + 'a>),
Push(Box<IArgsAction + 'a>),
Many(Box<IArgsAction + 'a>),
}
pub trait TypedAction<T> {
fn bind<'x>(&self, Rc<RefCell<&'x mut T>>) -> Action<'x>;
}
pub trait IFlagAction {
fn parse_flag(&self) -> ParseResult;
}
pub trait IArgAction {
fn parse_arg(&self, arg: &str) -> ParseResult;
}
pub trait IArgsAction {
fn parse_args(&self, args: &[&str]) -> ParseResult;
}
|