# HG changeset patch # User dermetfan # Date 1435271439 -7200 # Fri Jun 26 00:30:39 2015 +0200 # Node ID 58cff46a4c21460065f83f3f13fa8dbb259f95d3 # Parent 13bcf4e99788545559aeee6d18834de774278d34 don't even init ncurses if help flag is present diff --git a/src/main.rs b/src/main.rs --- a/src/main.rs +++ b/src/main.rs @@ -29,8 +29,6 @@ std::process::exit(code); }; - init_ncurses(); - const ARG_HELP: &'static str = "help"; const ARG_ROWS: &'static str = "rows"; const ARG_COLS: &'static str = "cols"; @@ -64,24 +62,25 @@ let matches = match options.parse(&args[1..]) { Ok(m) => m, Err(e) => { - end_ncurses(); print_help(false); exit_with_msg(1, &e.to_string()); unreachable!() } }; + if matches.opt_present(ARG_HELP) { + print_help(false); + std::process::exit(0); + } + + init_ncurses(); + let mut maxy = 0; let mut maxx = 0; getmaxyx(stdscr, &mut maxy, &mut maxx); let maxy = maxy; let maxx = maxx; - if matches.opt_present(ARG_HELP) { - end_ncurses(); - print_help(false); - std::process::exit(0); - } let rows = if matches.opt_present(ARG_ROWS) { matches.opt_str(ARG_ROWS).unwrap().parse::().unwrap_or_else(|_| { end_ncurses();