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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
pub
use OsStr;
use Debug;
pub use Infer;
pub use Placeholder;
pub use crateraw2str;
pub use crateAnyValue;
pub use crateErasedValue;
pub use crateInitHandler;
pub use crateInitializeValue;
pub use crateRawValParser;
pub use crateStoreHandler;
pub use crateValAccessor;
pub use crateValInitializer;
pub use crateValStorer;
pub use crateValValidator;
pub use crateValidatorHandler;
use crateCtx;
use crateError;
/// A special option value, can stop the policy, using for implement `--`.
///
/// # Example
/// ```
/// use aopt::prelude::*;
///
/// fn main() -> Result<(), Box<dyn std::error::Error>> {
///
/// let mut parser = AFwdParser::default();
///
/// parser.add_opt("stop".infer::<aopt::value::Stop>())?;
///
/// // -w will processed, it is set before `--`
/// parser.add_opt("-w=i")?;
///
/// // -o will not processed, it is set after `--`
/// parser.add_opt("-o=s")?;
///
/// // fo will processed, it is not an option
/// parser.add_opt("foo=p@1")?;
///
/// parser.parse(Args::from(["app", "-w=42", "--", "-o", "val", "foo"]))?;
///
/// assert_eq!(parser.find_val::<i64>("-w")?, &42);
/// assert!(parser.find_val::<String>("-o").is_err());
/// assert_eq!(parser.find_val::<bool>("foo")?, &true);
/// Ok(())
/// }
/// ```
///
/// ```plaintext
/// POSIX.1-2017
///
/// 12.2 Utility Syntax Guidelines
///
/// Guideline 10:
///
/// The first -- argument that is not an option-argument should be accepted as a delimiter indicating the end of options.
/// Any following arguments should be treated as operands, even if they begin with the '-' character.
/// ```
;
/// A special option value, using for implement `-`.
///
/// # Example
/// ```
/// use aopt::prelude::*;
///
/// fn main() -> Result<(), Box<dyn std::error::Error>> {
///
/// let mut parser = AFwdParser::default();
///
/// parser.set_strict(true);
/// parser.add_opt("stdin=b".infer::<std::io::Stdin>())?;
///
/// // -w will processed, it is set before `--`
/// parser.add_opt("-w=i")?;
///
/// // -o will not processed, it is set after `--`
/// parser.add_opt("-o=s")?;
///
/// // fo will processed, it is not an option
/// parser.add_opt("foo=p@1")?;
///
/// parser.parse(Args::from(
/// ["app", "-w=42", "-", "foo"].into_iter(),
/// ))?;
///
/// assert_eq!(parser.find_val::<i64>("-w")?, &42);
/// assert!(parser.find_val::<std::io::Stdin>("-").is_ok());
/// assert_eq!(parser.find_val::<bool>("foo")?, &true);
/// Ok(())
/// }
/// ```