minor changes

This commit is contained in:
2025-07-16 03:08:16 +02:00
parent e1555e1432
commit 167036e144
3 changed files with 112 additions and 7 deletions

View File

@@ -2,9 +2,12 @@ use clap::{Args, Parser, Subcommand};
use text_correction::utils;
use std::time::SystemTime;
use std::process::*;
use std::path::Path;
use spinners::{Spinner, Spinners};
use log::{error, trace};
#[derive(Parser)]
#[command(name = "german word corrector")]
#[command(name = "word corrector")]
#[command(version, about, long_about = None)]
#[command(next_line_help = true)]
struct Cli {
@@ -34,7 +37,9 @@ struct FileArgs {
#[arg(short,long)]
list_path: String,
#[arg(short,long)]
output: String
output: String,
#[arg(short,long)]
overwrite: bool
}
fn main() {
@@ -46,7 +51,20 @@ fn main() {
println!("{}", out);
},
Commands::CorrectFile(args) => {
utils::correct_file_concurr(args.input.clone(), args.list_path.as_str(), args.output.clone())
if args.overwrite == true {
trace!("Overwriting old file due to cli argument.");
std::fs::remove_file(args.output.clone()).unwrap();
} else {
trace!("Checking whether destination is writable.");
let path = "./".to_owned() + args.output.as_str();
if Path::new(path.as_str()).exists() {
error!("File already exists!");
exit(1);
}
}
let mut sp = Spinner::new(Spinners::Dots, "Processing file...".into());
utils::correct_file_concurr(args.input.clone(), args.list_path.as_str(), args.output.clone());
sp.stop_with_message("".into());
},
Commands::BenchFile(args) => {
let start_par = SystemTime::now();