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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// ---------------- [ File: bitcoin-argsman/src/query.rs ]
crate::ix!();
impl ArgsManagerInner {
/**
| Return true if the given argument has
| been manually set
|
| -----------
| @param strArg
|
| Argument to get (e.g. "-foo")
|
| -----------
| @return
|
| true if the argument has been set
|
*/
pub fn is_arg_set(&self, str_arg: &str) -> bool {
!self.get_setting(str_arg).0.is_null()
}
/**
| Return true if the argument was originally
| passed as a negated option, i.e. -nofoo.
|
| -----------
| @param strArg
|
| Argument to get (e.g. "-foo")
|
| -----------
| @return
|
| true if the argument was passed negated
|
*/
pub fn is_arg_negated(&self, str_arg: &str) -> bool {
self.get_setting(str_arg).0.is_false()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn is_arg_set_and_negated() {
let mut inner = ArgsManagerInner::default();
assert!(!inner.is_arg_set("-x"));
inner.force_set_arg("-x", "0"); // logical false
assert!(inner.is_arg_set("-x"));
assert!(inner.is_arg_negated("-x"));
inner.force_set_arg("-x", "1");
assert!(inner.is_arg_set("-x"));
assert!(!inner.is_arg_negated("-x"));
}
}