wrote the tool!

This commit is contained in:
pyro57000
2025-11-14 12:28:46 -06:00
parent 2ffad56c14
commit 89615627f0
4 changed files with 241 additions and 0 deletions

43
src/main.rs Normal file
View File

@@ -0,0 +1,43 @@
use clap::Parser;
use std::{
fs::{File, read_to_string},
io::Write,
path::PathBuf,
process::exit,
};
#[derive(Parser, Debug)]
#[command(
version,
about,
long_about = "This fixes files that sometimes get fucked up by Windows not using the stanard \\n notation for new lines."
)]
struct Args {
#[arg(short, long, help = "the file to fix")]
input: PathBuf,
#[arg(short, long, help = "the path to save the fixed file")]
output: PathBuf,
}
fn main() {
let args = Args::parse();
let file_read_res = read_to_string(args.input);
if file_read_res.is_err() {
println!("error reading broken file!");
println!("{}", file_read_res.err().unwrap());
exit(1);
}
let borked_string = file_read_res.unwrap();
let file_open_res = File::create_new(args.output);
if file_open_res.is_err() {
println!("error opening output file!");
println!("{}", file_open_res.err().unwrap());
exit(1);
}
let mut outfile = file_open_res.unwrap();
let fixed_lines: Vec<&str> = borked_string.split("\\n").collect();
for line in fixed_lines {
write!(outfile, "{}\n", line).unwrap();
}
}