fn parse_args_or_exit(style: ParsingStyle) -> Self where Self: Sized {
        use std::env::args;
        use std::process::exit;

        let args = args().collect::<Vec<_>>();

        let opts = Self::parse_args(&args[1..], style).unwrap_or_else(|e| {
            eprintln!("{}: {}", args[0], e);
            exit(2);
        });

        if opts.help_requested() {
            let mut command = &opts as &dyn Options;
            let mut command_str = String::new();

            loop {
                if let Some(new_command) = command.command() {
                    command = new_command;

                    if let Some(name) = new_command.command_name() {
                        command_str.push(' ');
                        command_str.push_str(name);
                    }
                } else {
                    break;
                }
            }

            println!("Usage: {}{} [OPTIONS]", args[0], command_str);
            println!();
            println!("{}", command.self_usage());

            if let Some(cmds) = command.self_command_list() {
                println!();
                println!("Available commands:");
                println!("{}", cmds);
            }

            exit(0);
        }

        opts
    }
/// Parses arguments from the environment.
///
/// If an error is encountered, the error is printed to `stderr` and the
/// process will exit with status code `2`.
///
/// If the user supplies a help option, option usage will be printed to
/// `stdout` and the process will exit with status code `0`.
///
/// Otherwise, the parsed options are returned.
Parses arguments from the environment.
If an error is encountered, the error is printed to `stderr` and the
process will exit with status code `2`.

If the user supplies a help option, option usage will be printed to
`stdout` and the process will exit with status code `0`.

Otherwise, the parsed options are returned.
Parses arguments from the environment . If an error is encountered the error is printed to ` stderr ` and the process will exit with status code ` 2 ` . If the user supplies a help option option usage will be printed to ` stdout ` and the process will exit with status code ` 0 ` . Otherwise the parsed options are returned .
fn parse_args_or_exit(style: ParsingStyle) -> Self where Self: Sized {
        use std::env::args;
        use std::process::exit;
        let args = args().collect::<Vec<_>>();
        let opts = Self::parse_args(&args[1..], style).unwrap_or_else(|e| {
            eprintln!("{}: {}", args[0], e);
            exit(2);
        });
        if opts.help_requested() {
            let mut command = &opts as &dyn Options;
            let mut command_str = String::new();
            loop {
                if let Some(new_command) = command.command() {
                    command = new_command;
                    if let Some(name) = new_command.command_name() {
                        command_str.push(' ');
                        command_str.push_str(name);
                    }
                } else {
                    break;
                }
            }
            println!("Usage: {}{} [OPTIONS]", args[0], command_str);
            println!();
            println!("{}", command.self_usage());
            if let Some(cmds) = command.self_command_list() {
                println!();
                println!("Available commands:");
                println!("{}", cmds);
            }
            exit(0);
        }
        opts
    }
fn parse_args_or_exit ( style : ParsingStyle ) -> Self where Self : Sized { use std :: env :: args ; use std :: process :: exit ; let args = args ( ) . collect :: < Vec < _ > > ( ) ; let opts = Self :: parse_args ( & args [ 1 .. ] , style ) . unwrap_or_else ( | e | { eprintln ! ( " " args [ 0 ] e ) ; exit ( 2 ) ; } ) ; if opts . help_requested ( ) { let mut command = & opts as & dyn Options ; let mut command_str = String :: new ( ) ; loop { if let Some ( new_command ) = command . command ( ) { command = new_command ; if let Some ( name ) = new_command . command_name ( ) { command_str . push ( ' ' ) ; command_str . push_str ( name ) ; } } else { break ; } } println ! ( " " args [ 0 ] command_str ) ; println ! ( ) ; println ! ( " " command self_usage ( ) ) ; if let Some ( cmds ) = command . self_command_list ( ) { println ! ( ) ; println ! ( " " ) ; println ! ( " " cmds ) ; } exit ( 0 ) ; } opts }
Parses arguments from the environment.
Parses arguments from the environment .
style
ParsingStyle
style
ParsingStyle