<commit_before>use std::env;
use std::io::{self, Read, BufReader};
use std::fs::File;

mod wires;


fn main() {
    let args: Vec<String> = env::args().collect();
    if args.len() == 2 {
        // let result = wires::strings_from_file(&args[1]);
        let fs_result = File::open(&args[1]);
        match fs_result {
            Ok(file) =>  {
                let mut reader = BufReader::new(file);
                let mut contents : Vec<u8> = Vec::new();
                let read_result = reader.read_to_end(&mut contents);
                match read_result {
                    Ok(_) => {
                        let stdout = io::stdout();
                        let mut handle = stdout.lock();
                        wires::bytes_to_strings(&contents, &mut handle);
                    },
                    Err(_) => println!("An error occurred reading the buffer")
                }
            },
            Err(_) => println!("Could not read from file.")

        }

    } else {
        println!("Please specify a path");
    }
}


<commit_msg>exit 1 if read fails<commit_after>use std::env;
use std::io::{self, Read, BufReader};
use std::fs::File;
use std::process; 

mod wires;


fn main() {
    let args: Vec<String> = env::args().collect();
    if args.len() == 2 {
        // let result = wires::strings_from_file(&args[1]);
        let fs_result = File::open(&args[1]);
        match fs_result {
            Ok(file) =>  {
                let mut reader = BufReader::new(file);
                let mut contents : Vec<u8> = Vec::new();
                let read_result = reader.read_to_end(&mut contents);
                match read_result {
                    Ok(_) => {
                        let stdout = io::stdout();
                        let mut handle = stdout.lock();
                        wires::bytes_to_strings(&contents, &mut handle);
                    },
                    Err(_) => {
                        println!("An error occurred reading the buffer");
                        process::exit(1);
                    }
                }
            },
            Err(_) => { 
                println!("Could not read from file.");
                process::exit(1);
            }

        }

    } else {
        println!("Please specify a path");
        process::exit(1); 
    }
}



{'fraction_non_alphanumeric': 0.13807890222984562, 'fraction_numerical': 0.005145797598627788, 'mean_word_length': 1.3879222108495395, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '5722254', 'n_tokens_mistral': 664, 'n_tokens_neox': 617, 'n_words': 153}