1pub(crate) mod action;
2pub(crate) mod index;
3pub(crate) mod style;
4
5use std::any::TypeId;
6use std::fmt::Debug;
7
8use crate::value::ValAccessor;
9use crate::Error;
10use crate::Uid;
11
12pub use self::action::Action;
13pub use self::index::Index;
14pub use self::style::Style;
15
16pub const BOOL_TRUE: &str = "true";
17
18pub const BOOL_FALSE: &str = "false";
19
20pub trait Opt: Debug {
21 fn reset(&mut self);
22
23 fn uid(&self) -> Uid;
25
26 fn name(&self) -> &str;
28
29 fn r#type(&self) -> &TypeId;
31
32 fn hint(&self) -> &str;
34
35 fn help(&self) -> &str;
37
38 fn valid(&self) -> bool;
39
40 fn matched(&self) -> bool;
42
43 fn force(&self) -> bool;
45
46 fn action(&self) -> &Action;
48
49 fn index(&self) -> Option<&Index>;
51
52 fn alias(&self) -> Option<&Vec<String>>;
54
55 fn accessor(&self) -> &ValAccessor;
56
57 fn accessor_mut(&mut self) -> &mut ValAccessor;
58
59 fn ignore_alias(&self) -> bool;
60
61 fn ignore_name(&self) -> bool;
62
63 fn ignore_index(&self) -> bool;
64
65 fn set_uid(&mut self, uid: Uid);
66
67 fn set_matched(&mut self, matched: bool);
68
69 fn mat_style(&self, style: Style) -> bool;
70
71 fn mat_force(&self, force: bool) -> bool;
72
73 fn mat_name(&self, name: Option<&str>) -> bool;
74
75 fn mat_alias(&self, name: &str) -> bool;
76
77 fn mat_index(&self, index: Option<(usize, usize)>) -> bool;
78
79 fn init(&mut self) -> Result<(), Error>;
80
81 fn set_name(&mut self, name: impl Into<String>) -> &mut Self;
82
83 fn set_type(&mut self, r#type: TypeId) -> &mut Self;
84
85 fn set_value(&mut self, value: ValAccessor) -> &mut Self;
86
87 fn set_hint(&mut self, hint: impl Into<String>) -> &mut Self;
88
89 fn set_help(&mut self, help: impl Into<String>) -> &mut Self;
90
91 fn set_action(&mut self, action: Action) -> &mut Self;
92
93 fn set_style(&mut self, styles: Vec<Style>) -> &mut Self;
94
95 fn set_index(&mut self, index: Option<Index>) -> &mut Self;
96
97 fn set_force(&mut self, force: bool) -> &mut Self;
98
99 fn add_alias(&mut self, name: impl Into<String>) -> &mut Self;
100
101 fn rem_alias(&mut self, name: &str) -> &mut Self;
102
103 fn set_ignore_name(&mut self, ignore_name: bool) -> &mut Self;
104
105 fn set_ignore_alias(&mut self, ignore_alias: bool) -> &mut Self;
106
107 fn set_ignore_index(&mut self, ignore_index: bool) -> &mut Self;
108}