add: use BufReader for line by line reading

This commit is contained in:
2026-08-23 12:35:18 +05:30
parent dd48c9dfe3
commit 27cd5943a1
+10 -7
View File
@@ -1,22 +1,25 @@
#![allow(unused_imports)]
use std::env;
use std::fs;
use std::fs::File;
use std::io::{BufRead, BufReader};
use log::{debug, error, info, trace, warn};
use plume_log::{PlumeBuilder, success};
fn main(){
fn main() -> std::io::Result<()>{
PlumeBuilder::new()
.with_level(log::LevelFilter::Trace)
.init()
.expect("Failed to init the logger");
let args: Vec<String> = env::args().collect();
let file_path = &args[1];
info!("{}", file_path);
info!("File: {}", &args[1]);
let file = File::open(&args[1])?;
let reader = BufReader::new(file);
let contents = fs::read_to_string(file_path)
.expect("File can't be read");
for line in reader.lines() {
println!("+ {}", line?);
}
println!("{}", contents);
Ok(())
}