Expand description
Struct of information for parse
Fields
flag_pattern: char
flag_pattern. Default is ‘-’.
long_flag_prefix: String
Long-flag prefix. Default is “–”.
eq: char
equal symbol. Default is “=”
Implementations
sourceimpl Parser
impl Parser
sourcepub fn new(flag_pattern: char, long_flag_prefix: &str) -> Parser
pub fn new(flag_pattern: char, long_flag_prefix: &str) -> Parser
Creates a new Parser with flag_pattern and long_flag_prefix.
sourcepub fn long_flag(&self, str: &str) -> bool
pub fn long_flag(&self, str: &str) -> bool
Returns true if str has long-flag prefix (default prefix: –). ロングフラグか判定する
sourcepub fn flag(&self, str: &str) -> bool
pub fn flag(&self, str: &str) -> bool
Returns true if str has flag prefix (default prefix: -). フラグならtrueを返す
sourcepub fn with_all_field(
flag_pattern: char,
long_flag_prefix: String,
eq: char
) -> Parser
pub fn with_all_field(
flag_pattern: char,
long_flag_prefix: String,
eq: char
) -> Parser
Builds a new Parser with all options
sourcepub fn remove_long_flag_prefix(&self, arg: String) -> String
pub fn remove_long_flag_prefix(&self, arg: String) -> String
Removes long-flag prefix from arg.
sourcepub fn get_short_flag_name(&self, arg: String) -> String
pub fn get_short_flag_name(&self, arg: String) -> String
Gets short flag name.
sourcepub fn middle_parse(
&self,
args: VecDeque<String>,
inter_mediate_args: VecDeque<MiddleArg>,
last: MiddleArg
) -> (Option<String>, VecDeque<String>, VecDeque<MiddleArg>, MiddleArg)
pub fn middle_parse(
&self,
args: VecDeque<String>,
inter_mediate_args: VecDeque<MiddleArg>,
last: MiddleArg
) -> (Option<String>, VecDeque<String>, VecDeque<MiddleArg>, MiddleArg)
Parses args and convert into MiddileArgs
sourcepub fn long_middle(&self, long_flag: String) -> MiddleArg
pub fn long_middle(&self, long_flag: String) -> MiddleArg
Converts long_flag to MiddleArg::LongFlag.
sourcepub fn short_middle(&self, short_flag: String) -> MiddleArg
pub fn short_middle(&self, short_flag: String) -> MiddleArg
Converts short_flag to MiddleArg::ShortFlag.
sourcepub fn parse_inter_mediate_args<T: FlagSearch, S: FlagSearch>(
&self,
local_flags: &T,
current_common_flags: &S,
c: Context,
flag_only: bool
) -> (Context, Option<VecDeque<String>>)
pub fn parse_inter_mediate_args<T: FlagSearch, S: FlagSearch>(
&self,
local_flags: &T,
current_common_flags: &S,
c: Context,
flag_only: bool
) -> (Context, Option<VecDeque<String>>)
Parses c’s parsing_args (call inter mediate args in parsing).
sourcepub fn parse_middle_long_flag<T: FlagSearch, S: FlagSearch>(
&self,
name_or_alias: String,
val: FlagValue,
local_flags: &T,
current_common_flags: &S,
c: &Context,
l_flags: VecDeque<(String, FlagValue)>,
c_flags: VecDeque<(String, FlagValue)>,
e_list: VecDeque<ErrorInfo>
) -> (VecDeque<(String, FlagValue)>, VecDeque<(String, FlagValue)>, VecDeque<ErrorInfo>)
pub fn parse_middle_long_flag<T: FlagSearch, S: FlagSearch>(
&self,
name_or_alias: String,
val: FlagValue,
local_flags: &T,
current_common_flags: &S,
c: &Context,
l_flags: VecDeque<(String, FlagValue)>,
c_flags: VecDeque<(String, FlagValue)>,
e_list: VecDeque<ErrorInfo>
) -> (VecDeque<(String, FlagValue)>, VecDeque<(String, FlagValue)>, VecDeque<ErrorInfo>)
Parses middle long flag.
sourcepub fn parse_middle_short_flag<T: FlagSearch, S: FlagSearch>(
&self,
short_alias: String,
flag_val: FlagValue,
local_flags: &T,
current_common_flags: &S,
c: &Context,
l_flags: VecDeque<(String, FlagValue)>,
c_flags: VecDeque<(String, FlagValue)>,
e_list: VecDeque<ErrorInfo>
) -> (VecDeque<(String, FlagValue)>, VecDeque<(String, FlagValue)>, VecDeque<ErrorInfo>)
pub fn parse_middle_short_flag<T: FlagSearch, S: FlagSearch>(
&self,
short_alias: String,
flag_val: FlagValue,
local_flags: &T,
current_common_flags: &S,
c: &Context,
l_flags: VecDeque<(String, FlagValue)>,
c_flags: VecDeque<(String, FlagValue)>,
e_list: VecDeque<ErrorInfo>
) -> (VecDeque<(String, FlagValue)>, VecDeque<(String, FlagValue)>, VecDeque<ErrorInfo>)
Parse middle short flag
sourcepub fn parse_middle_normal_arg<T: FlagSearch, S: FlagSearch>(
&self,
inter_mediate_args: VecDeque<MiddleArg>,
normal_arg: String,
local_flags: &T,
current_common_flags: &S,
c: Context,
non_flag_args: VecDeque<String>,
l_flags: VecDeque<(String, FlagValue)>,
c_flags: VecDeque<(String, FlagValue)>,
e_list: VecDeque<ErrorInfo>,
flag_only: bool
) -> (Context, VecDeque<MiddleArg>, VecDeque<String>, VecDeque<(String, FlagValue)>, VecDeque<(String, FlagValue)>, VecDeque<ErrorInfo>)
pub fn parse_middle_normal_arg<T: FlagSearch, S: FlagSearch>(
&self,
inter_mediate_args: VecDeque<MiddleArg>,
normal_arg: String,
local_flags: &T,
current_common_flags: &S,
c: Context,
non_flag_args: VecDeque<String>,
l_flags: VecDeque<(String, FlagValue)>,
c_flags: VecDeque<(String, FlagValue)>,
e_list: VecDeque<ErrorInfo>,
flag_only: bool
) -> (Context, VecDeque<MiddleArg>, VecDeque<String>, VecDeque<(String, FlagValue)>, VecDeque<(String, FlagValue)>, VecDeque<ErrorInfo>)
Parse middle normal arg
sourcepub fn parse_next_if_middle_arg<T: FlagSearch, S: FlagSearch>(
&self,
inter_mediate_args: VecDeque<MiddleArg>,
non_flag_args: VecDeque<String>,
local_flags: &T,
current_common_flags: &S,
c: Context,
l_flags: VecDeque<(String, FlagValue)>,
c_flags: VecDeque<(String, FlagValue)>,
e_list: VecDeque<ErrorInfo>,
flag_only: bool
) -> (Context, VecDeque<MiddleArg>, VecDeque<String>, VecDeque<(String, FlagValue)>, VecDeque<(String, FlagValue)>, VecDeque<ErrorInfo>)
pub fn parse_next_if_middle_arg<T: FlagSearch, S: FlagSearch>(
&self,
inter_mediate_args: VecDeque<MiddleArg>,
non_flag_args: VecDeque<String>,
local_flags: &T,
current_common_flags: &S,
c: Context,
l_flags: VecDeque<(String, FlagValue)>,
c_flags: VecDeque<(String, FlagValue)>,
e_list: VecDeque<ErrorInfo>,
flag_only: bool
) -> (Context, VecDeque<MiddleArg>, VecDeque<String>, VecDeque<(String, FlagValue)>, VecDeque<(String, FlagValue)>, VecDeque<ErrorInfo>)
Parses args if next middle args exist.
sourcepub fn parse_args_until_end<T: FlagSearch, S: FlagSearch>(
self,
local_flags: &T,
current_common_flags: &S,
c: Context
) -> Context
pub fn parse_args_until_end<T: FlagSearch, S: FlagSearch>(
self,
local_flags: &T,
current_common_flags: &S,
c: Context
) -> Context
Parse args until args’ end.
sourcepub fn parse_flags_start_with_long_flag<T: FlagSearch, S: FlagSearch>(
&self,
long_flag: String,
local_flags: &T,
current_common_flags: &S,
c: Context
) -> (Option<String>, Context)
pub fn parse_flags_start_with_long_flag<T: FlagSearch, S: FlagSearch>(
&self,
long_flag: String,
local_flags: &T,
current_common_flags: &S,
c: Context
) -> (Option<String>, Context)
Parses flags start with long flag until non-flag arg appeared.
sourcepub fn parse_flags_start_with_short_flag<T: FlagSearch, S: FlagSearch>(
&self,
short_flag: String,
local_flags: &T,
current_common_flags: &S,
c: Context
) -> (Option<String>, Context)
pub fn parse_flags_start_with_short_flag<T: FlagSearch, S: FlagSearch>(
&self,
short_flag: String,
local_flags: &T,
current_common_flags: &S,
c: Context
) -> (Option<String>, Context)
Parses flags start with short flag until args appeared.
sourcepub fn parse_next_if_flag<T: FlagSearch, S: FlagSearch>(
&self,
local_flags: &T,
current_common_flags: &S,
c: Context
) -> (Option<String>, Context)
pub fn parse_next_if_flag<T: FlagSearch, S: FlagSearch>(
&self,
local_flags: &T,
current_common_flags: &S,
c: Context
) -> (Option<String>, Context)
Parses(or assigns parse functions) args if next args.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Parser
impl Send for Parser
impl Sync for Parser
impl Unpin for Parser
impl UnwindSafe for Parser
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more