pub struct Args<'a> { /* private fields */ }
Implementations
sourceimpl<'a> Args<'a>
impl<'a> Args<'a>
sourcepub fn new(text: &'a str) -> Args<'_>
pub fn new(text: &'a str) -> Args<'_>
provide a usage string from which we extract flag definitions
sourcepub fn start(self, istart: usize) -> Self
pub fn start(self, istart: usize) -> Self
start offset in program command-line arguments. This defaults to 1, but e.g. for Cargo subcommands it would be 2
sourcepub fn user_types(&mut self, types: &[&str])
pub fn user_types(&mut self, types: &[&str])
declare any user-defined types to be used in the spec. (They will need to implement FromStr)
sourcepub fn quit(&self, msg: &str) -> !
pub fn quit(&self, msg: &str) -> !
bail out of program with non-zero return code. May force this to panic instead with the LAPP_PANIC environment variable.
sourcepub fn declarations(&mut self, struct_name: &str) -> String
pub fn declarations(&mut self, struct_name: &str) -> String
create suggested variable or struct declarations for accessing the flags…
pub fn dump(&mut self)
pub fn parse_env_args(&mut self) -> Result<()>
sourcepub fn parse_result(&mut self) -> Result<()>
pub fn parse_result(&mut self) -> Result<()>
parse the spec and the command-line
sourcepub fn parse_spec(&mut self) -> Result<()>
pub fn parse_spec(&mut self) -> Result<()>
parse the spec and create the flags.
pub fn parse_command_line(&mut self, v: Vec<String>) -> Result<()>
sourcepub fn clear_used(&mut self)
pub fn clear_used(&mut self)
clear used flag state
sourcepub fn flag_present(&self, name: &str) -> bool
pub fn flag_present(&self, name: &str) -> bool
has this flag been set? Quits if it’s an unknown flag
sourcepub fn get_string_result(&self, name: &str) -> Result<String>
pub fn get_string_result(&self, name: &str) -> Result<String>
get flag as a string
sourcepub fn get_integer_result(&self, name: &str) -> Result<i32>
pub fn get_integer_result(&self, name: &str) -> Result<i32>
get flag as an integer
sourcepub fn get_float_result(&self, name: &str) -> Result<f32>
pub fn get_float_result(&self, name: &str) -> Result<f32>
get flag as a float
sourcepub fn get_bool_result(&self, name: &str) -> Result<bool>
pub fn get_bool_result(&self, name: &str) -> Result<bool>
get flag as boolean
sourcepub fn get_infile_result(&self, name: &str) -> Result<Box<dyn Read>>
pub fn get_infile_result(&self, name: &str) -> Result<Box<dyn Read>>
get flag as a file for reading
sourcepub fn get_outfile_result(&self, name: &str) -> Result<Box<dyn Write>>
pub fn get_outfile_result(&self, name: &str) -> Result<Box<dyn Write>>
get flag as a file for writing
sourcepub fn get_path_result(&self, name: &str) -> Result<PathBuf>
pub fn get_path_result(&self, name: &str) -> Result<PathBuf>
get flag as a path
sourcepub fn get_text_result(&self, name: &str) -> Result<&String>
pub fn get_text_result(&self, name: &str) -> Result<&String>
get flag always as text, if it’s defined
sourcepub fn get_result<T>(&self, name: &str) -> Result<T>where
T: FromStr,
<T as FromStr>::Err: Display,
pub fn get_result<T>(&self, name: &str) -> Result<T>where
T: FromStr,
<T as FromStr>::Err: Display,
get flag as any value which can parsed from a string.
sourcepub fn get_string(&self, name: &str) -> String
pub fn get_string(&self, name: &str) -> String
get flag as a string, quitting otherwise.
sourcepub fn get_integer(&self, name: &str) -> i32
pub fn get_integer(&self, name: &str) -> i32
get flag as an integer, quitting otherwise.
sourcepub fn get_infile(&self, name: &str) -> Box<dyn Read>
pub fn get_infile(&self, name: &str) -> Box<dyn Read>
get flag as a file for reading, quitting otherwise.
sourcepub fn get_outfile(&self, name: &str) -> Box<dyn Write>
pub fn get_outfile(&self, name: &str) -> Box<dyn Write>
get flag as a file for writing, quitting otherwise.
sourcepub fn get<T>(&self, name: &str) -> Twhere
T: FromStr,
<T as FromStr>::Err: Display,
pub fn get<T>(&self, name: &str) -> Twhere
T: FromStr,
<T as FromStr>::Err: Display,
get flag as any value which can parsed from a string, quitting otherwise.
sourcepub fn get_strings_result(&self, name: &str) -> Result<Vec<String>>
pub fn get_strings_result(&self, name: &str) -> Result<Vec<String>>
get a multiple flag as an array of strings
sourcepub fn get_integers_result(&self, name: &str) -> Result<Vec<i32>>
pub fn get_integers_result(&self, name: &str) -> Result<Vec<i32>>
get a multiple flag as an array of integers
sourcepub fn get_floats_result(&self, name: &str) -> Result<Vec<f32>>
pub fn get_floats_result(&self, name: &str) -> Result<Vec<f32>>
get a multiple flag as an array of floats
sourcepub fn get_results<T>(&self, name: &str) -> Result<Vec<T>>where
T: FromStr,
<T as FromStr>::Err: Display,
pub fn get_results<T>(&self, name: &str) -> Result<Vec<T>>where
T: FromStr,
<T as FromStr>::Err: Display,
get a multiple flag as an array of any parsable value.
sourcepub fn get_strings(&self, name: &str) -> Vec<String>
pub fn get_strings(&self, name: &str) -> Vec<String>
get a multiple flag as an array of strings, quitting otherwise
sourcepub fn get_integers(&self, name: &str) -> Vec<i32>
pub fn get_integers(&self, name: &str) -> Vec<i32>
get a multiple flag as an array of integers, quitting otherwise
sourcepub fn get_floats(&self, name: &str) -> Vec<f32>
pub fn get_floats(&self, name: &str) -> Vec<f32>
get a multiple flag as an array of floats, quitting otherwise