Struct app::Helper
[−]
[src]
pub struct Helper { /* fields omitted */ }
Helper
Methods
impl Helper
[src]
fn name(&self) -> &String
[src]
name
fn version(&self) -> &String
[src]
version
fn desc(&self) -> &String
[src]
description
[src]
name, email
fn addrs(&self) -> &Vec<(String, String)>
[src]
url_name, url
impl Helper
[src]
fn current_cmd(&self) -> Option<&String>
[src]
fn current_cmd_str(&self) -> Option<&str>
[src]
fn current_cmd_ref(&self) -> &Option<String>
[src]
fn current_exe(&self) -> Option<&String>
[src]
fn current_dir(&self) -> Option<&String>
[src]
fn home_dir(&self) -> Option<&String>
[src]
fn temp_dir(&self) -> &String
[src]
fn args_len(&self) -> &usize
[src]
You can do something if the length of arguments satisfys a condition.
Example: Print the help message when args.len() is 0.
let helper= {
...
};
if helper.args_len() == 0
{
helper.help_exit(0);
}
fn as_helps(&self) -> &Helps
[src]
fn as_mut_helps(&mut self) -> &mut Helps
[src]
impl Helper
[src]
fn exit(&self, status: i32)
[src]
exit with the status
fn ver(&self) -> &String
[src]
format!("{} {}", self.name(), self.version())
fn ver_exit(&self, status: i32)
[src]
print ver(self.ver
) message and exit with the status
fn err<E>(&self, error: E) -> String where
E: AsRef<str> + Display,
[src]
E: AsRef<str> + Display,
format!("ERROR:\n {}\n\n", error)
fn err_exit<E>(&self, error: E, status: i32) where
E: AsRef<str> + Display,
[src]
E: AsRef<str> + Display,
print error(self.err(error)
) message to stderr
and exit with the status
fn err_line_print(&self, msg: &str, line_color: u16)
[src]
print error message line(2) with Red color(fg)
fn help(&self) -> String
[src]
main's help mesage
fn help_exit(&self, status: i32)
[src]
print main's help message and exit with the status
fn help_err<E>(&self, error: E) -> String where
E: AsRef<str> + Display,
[src]
E: AsRef<str> + Display,
self.err(error) + self.help()
fn help_err_exit<E>(&self, error: E, status: i32) where
E: AsRef<str> + Display,
[src]
E: AsRef<str> + Display,
print error and help message(self.help_err(error)
) to stderr
and exit with the status
fn help_cmd(&self, cmd_name: &Option<String>) -> String
[src]
get sub_command's help message
fn help_cmd_exit(&self, cmd_name: &Option<String>, status: i32)
[src]
print sub_command's help message and exit with the status
fn help_cmd_err<E>(&self, cmd_name: &Option<String>, error: E) -> String where
E: AsRef<str> + Display,
[src]
E: AsRef<str> + Display,
self.err(error) + self.help_cmd(cmd_name)
fn help_cmd_err_exit<E>(&self, cmd_name: &Option<String>, error: E, status: i32) where
E: AsRef<str> + Display,
[src]
E: AsRef<str> + Display,
print error and sub_command's help message to stderr
,s exit with the status