pub struct Stop;Expand description
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(())
}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.Trait Implementations§
Source§impl<'de> Deserialize<'de> for Stop
impl<'de> Deserialize<'de> for Stop
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Infer for Stop
impl Infer for Stop
Source§fn infer_tweak_info<C>(cfg: &mut C) -> Result<(), Error>
fn infer_tweak_info<C>(cfg: &mut C) -> Result<(), Error>
For type Stop, swap the name and default alias(--) when build configuration.
type Val = Stop
fn infer_act() -> Action
fn infer_style() -> Vec<Style>
fn infer_ignore_alias() -> bool
fn infer_map(val: Self::Val) -> Self
fn infer_force() -> bool
fn infer_ctor() -> String
fn infer_index() -> Option<Index>
fn infer_ignore_name() -> bool
fn infer_ignore_index() -> bool
fn infer_validator() -> Option<ValValidator<Self::Val>>
fn infer_initializer() -> Option<ValInitializer>
fn infer_type_id() -> TypeId
fn infer_mutable(&mut self, val: Self::Val)where
Self: Sized,
fn infer_fill_info<C>(cfg: &mut C) -> Result<(), Error>
Source§impl Ord for Stop
impl Ord for Stop
Source§impl PartialOrd for Stop
impl PartialOrd for Stop
Source§impl RawValParser for Stop
impl RawValParser for Stop
impl Copy for Stop
impl Eq for Stop
impl StructuralPartialEq for Stop
Auto Trait Implementations§
impl Freeze for Stop
impl RefUnwindSafe for Stop
impl Send for Stop
impl Sync for Stop
impl Unpin for Stop
impl UnsafeUnpin for Stop
impl UnwindSafe for Stop
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more