extern crate argparse;

use argparse::{ArgumentParser, StoreTrue, Store, StoreOption, Print};

fn main() {
    let mut debug = false;
    let mut path = "".to_string();
    let mut file: Option<String> = None;
    { // block limits of borrows by refer() method calls
        let mut ap = ArgumentParser::new();
        ap.add_option(&["-v", "--version"], Print(env!("CARGO_PKG_VERSION").to_string()), "show version");
        ap.refer(&mut debug).add_option(&["-d", "--debug"], StoreTrue, "enable debug output");
        ap.refer(&mut file).add_option(&["-f", "--file"], StoreOption, "possible alternates file, - for stdin");
        ap.refer(&mut path).add_argument("PATH", Store, "path to find alternate for").required();
        ap.parse_args_or_exit();
    }

    println!("required path: {}", path);

    if let Some(unwrapped_file) = file {
        println!("file: {}", unwrapped_file);
    }

    println!("debug: {}", debug);
}

extern crate argparse;

use argparse::{ArgumentParser, StoreTrue, Store, StoreOption, Print};
use std::io::BufRead;

struct Options {
    debug: bool,
    path: String,
    file: Option<String>
}

fn main() {
    let mut options = Options {
        debug: false,
        path: "".to_string(),
        file: None
    };

    { // block limits of borrows by refer() method calls
        let mut ap = ArgumentParser::new();
        ap.add_option(&["-v", "--version"], Print(env!("CARGO_PKG_VERSION").to_string()), "show version");
        ap.refer(&mut options.debug).add_option(&["-d", "--debug"], StoreTrue, "enable debug output");
        ap.refer(&mut options.file).add_option(&["-f", "--file"], StoreOption, "possible alternates file, - for stdin");
        ap.refer(&mut options.path).add_argument("PATH", Store, "path to find alternate for").required();
        ap.parse_args_or_exit();
    }

    println!("required path: {}", options.path);

    if let Some(unwrapped_file) = options.file {
        println!("file: {}", unwrapped_file);
        if unwrapped_file == "-" {
            let stdin = std::io::stdin();
            for line in stdin.lock().lines() {
              println!("{}", line.unwrap());
            }
        } else {
          println!("Figure out how open and read actual file");
        }
    }

    println!("debug: {}", options.debug);
}

Add options struct & optionals
Add options struct & optionals

Why you made the change:

I did this so that the code would be a bit cleaner.
