pub enum Opt {
NonOption(String),
Dash,
Short(String),
ShortPair(String, String),
ShortIncomplete(String),
Long(String),
LongPair(String, String),
Terminator,
}Expand description
All possible options/non-options which can be parsed from arguments
Variants§
NonOption(String)
file (plain non-option argument)
Dash
- (just a dash; usually for stdin)
Short(String)
-x alphanumeric character “x”
ShortPair(String, String)
-xBAR or -x BAR
ShortIncomplete(String)
-x <EOF> (expected pair; found EOF)
Long(String)
--example
LongPair(String, String)
--example=[value]
Terminator
-- (forces all later arguments to be non-options)
Implementations§
Source§impl Opt
impl Opt
Sourcepub fn simplify(&self) -> SimpleOpt<'_>
pub fn simplify(&self) -> SimpleOpt<'_>
Converts an Opt into a SimpleOpt.
See SimpleOpt variants for a description of the variant conversion.
§Examples
Consider the following command:
$ program arg1 -abcx12 -y 3 --long --key=value - arg2 -- -kh --ignoreThe following code simulates parsing of the command above:
use argsyn::ArgsExt;
let cmd = "program arg1 -abcx12 -y 3 --long --key=value - arg2 -- -kh --ignore";
let args = cmd
.split_ascii_whitespace()
.into_iter()
.map(|s| s.to_string());
for opt in args.opts("xy").unwrap() {
println!("{:?}", opt.simplify());
}Running the above code produces the following output:
Basic("program")
Basic("arg1")
Flag("a")
Flag("b")
Flag("c")
Pair("x", "12")
Pair("y", "3")
Flag("long")
Pair("key", "value")
Stdin
Basic("arg2")
Done
Basic("-kh")
Basic("--ignore")See ArgsExt::opts for the same example but without simplification.
Trait Implementations§
Source§impl Ord for Opt
impl Ord for Opt
Source§impl PartialOrd for Opt
impl PartialOrd for Opt
impl Eq for Opt
impl StructuralPartialEq for Opt
Auto Trait Implementations§
impl Freeze for Opt
impl RefUnwindSafe for Opt
impl Send for Opt
impl Sync for Opt
impl Unpin for Opt
impl UnwindSafe for Opt
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