aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2016-04-23 02:48:18 -0400
committerTeddy Wing2016-04-23 02:48:18 -0400
commitad9ac4ec473ee23f6ca58c24fc33b1cb70520b83 (patch)
treeb0cc7ecd518e4204744d8ba7764189f05d79dbdd
parent0b12b2bae1130746ed49cc3c7a2daa819ede1b58 (diff)
downloadmutt-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.
-rw-r--r--Cargo.lock8
-rw-r--r--Cargo.toml1
-rw-r--r--src/main.rs13
3 files changed, 2 insertions, 20 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 8db7560..81030eb 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,12 +1,4 @@
[root]
name = "alias-auto-add"
version = "0.0.1"
-dependencies = [
- "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "getopts"
-version = "0.2.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index 582992c..4fa9b0b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,4 +3,3 @@ name = "alias-auto-add"
version = "0.0.1"
[dependencies]
-getopts = "0.2"
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;