From ad9ac4ec473ee23f6ca58c24fc33b1cb70520b83 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sat, 23 Apr 2016 02:48:18 -0400 Subject: Remove dependency on 'getopts' As described in 0b12b2bae1130746ed49cc3c7a2daa819ede1b58, we don't need to depend on 'getopts' because we don't have any command line options, just a single required argument. Rewrite our code to factor out getopts and assume that the first argument to our program is an alias file path. --- src/main.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 6b9d79e..75e74ac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,3 @@ -extern crate getopts; - -use getopts::Options; use std::env; use std::error::{self, Error}; use std::io::{self, BufRead, BufReader, Write}; @@ -168,15 +165,9 @@ fn print_usage(program: &str) { fn main() { let args: Vec = env::args().collect(); let program = args[0].clone(); - let opts = Options::new(); - - let opt_matches = match opts.parse(&args[1..]) { - Ok(m) => m, - Err(f) => panic!(f.to_string()), - }; - let file = if !opt_matches.free.is_empty() { - opt_matches.free[0].clone() + let file = if args.len() > 1 { + &args[1] } else { print_usage(&program); return; -- cgit v1.2.3