diff options
| author | Teddy Wing | 2016-04-23 02:48:18 -0400 | 
|---|---|---|
| committer | Teddy Wing | 2016-04-23 02:48:18 -0400 | 
| commit | ad9ac4ec473ee23f6ca58c24fc33b1cb70520b83 (patch) | |
| tree | b0cc7ecd518e4204744d8ba7764189f05d79dbdd /src | |
| parent | 0b12b2bae1130746ed49cc3c7a2daa819ede1b58 (diff) | |
| download | mutt-alias-auto-add-ad9ac4ec473ee23f6ca58c24fc33b1cb70520b83.tar.bz2 | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 13 | 
1 files changed, 2 insertions, 11 deletions
| 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<String> = 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; | 
