print file content

This commit is contained in:
2021-09-20 00:05:25 +02:00
parent 4ce610fab9
commit e3a68f26c8

View File

@@ -1,3 +1,23 @@
use std::env;
use std::fs;
use std::io::{stdin, stdout, BufReader, Read};
fn main() {
println!("Hello, world!");
let file_name = match env::args().nth(1){
None => {
println!("Usage: rbfckr <filename>");
return;
}
Some(file_name) => file_name,
};
let bf_code = match fs::read_to_string(file_name) {
Ok(bf_code) => bf_code,
Err(e) => {
println!("Error reading file: {}", e);
return;
}
};
println!("{}", bf_code);
}