<commit_before>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);
}<commit_msg>Add options struct & optionals<commit_after>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);
}
{'fraction_non_alphanumeric': 0.1753055204382638, 'fraction_numerical': 0.0, 'mean_word_length': 2.9899159663865547, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3974473', 'n_tokens_mistral': 716, 'n_tokens_neox': 717, 'n_words': 184}