pub struct Helper { /* private fields */ }
Expand description
Helper
Implementations§
Source§impl Helper
impl Helper
pub fn current_cmd(&self) -> Option<&String>
pub fn current_cmd_str(&self) -> Option<&str>
pub fn current_cmd_ref(&self) -> &Option<String>
pub fn current_exe(&self) -> Option<&String>
pub fn current_dir(&self) -> Option<&String>
pub fn home_dir(&self) -> Option<&String>
pub fn temp_dir(&self) -> &String
Sourcepub fn args_len(&self) -> &usize
pub fn args_len(&self) -> &usize
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);
}
pub fn as_helps(&self) -> &Helps
pub fn as_mut_helps(&mut self) -> &mut Helps
Source§impl Helper
impl Helper
Sourcepub fn err_exit<E>(&self, error: E, status: i32)
pub fn err_exit<E>(&self, error: E, status: i32)
print error(self.err(error)
) message to stderr
and exit with the status
Sourcepub fn err_line_print(&self, msg: &str, line_color: Color)
pub fn err_line_print(&self, msg: &str, line_color: Color)
print error message line(2) with Red color(fg)
Sourcepub fn help_err_exit<E>(&self, error: E, status: i32)
pub fn help_err_exit<E>(&self, error: E, status: i32)
print error and help message(self.help_err(error)
) to stderr
and exit with the status
Sourcepub fn help_cmd_exit(&self, cmd_name: &Option<String>, status: i32)
pub fn help_cmd_exit(&self, cmd_name: &Option<String>, status: i32)
print sub_command’s help message and exit with the status
Sourcepub fn help_cmd_err<E>(&self, cmd_name: &Option<String>, error: E) -> String
pub fn help_cmd_err<E>(&self, cmd_name: &Option<String>, error: E) -> String
self.err(error) + self.help_cmd(cmd_name)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Helper
impl RefUnwindSafe for Helper
impl Send for Helper
impl Sync for Helper
impl Unpin for Helper
impl UnwindSafe for Helper
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