Skip to content

Commit

Permalink
Add removal-marker-target-config option
Browse files Browse the repository at this point in the history
  • Loading branch information
piyoppi committed Nov 21, 2024
1 parent 50afdc4 commit 0edff2a
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use chiritori::{ChiritoriConfiguration, MarkerTagConfiguration, TimeLimitedConfi
use clap::Parser;
use std::collections::HashSet;
use std::fs::File;
use std::io::prelude::*;
use std::io::{prelude::*, BufReader};
use std::rc::Rc;
mod chiritori;
mod code;
Expand Down Expand Up @@ -49,6 +49,11 @@ struct Args {
#[arg(long, default_value = "vec![]")]
removal_marker_target_name: Vec<String>,

/// Config file specifying the name of the removal-marker to be removed.
/// The content of the config file is indicated by the name of the removal target, separated by a newline.
#[arg(long)]
removal_marker_target_config: Option<String>,

/// List source code to be removed
#[arg(short, long)]
list: bool,
Expand Down Expand Up @@ -77,8 +82,16 @@ fn main() {
.expect("something went wrong reading the file");
}

let content = Rc::new(content);
let marker_removal_tags = HashSet::from_iter(args.removal_marker_target_name);
let removal_marker_target_names_from_file = if let Some(removal_marker_target_config) = args.removal_marker_target_config {
let f = File::open(removal_marker_target_config).expect("file not found");
let reader = BufReader::new(f);

reader.lines().map_while(Result::ok).collect::<Vec<_>>()
} else {
vec![]
};

let marker_removal_tags: HashSet<_> = removal_marker_target_names_from_file.into_iter().chain(args.removal_marker_target_name).collect();

let config = ChiritoriConfiguration {
time_limited_configuration: TimeLimitedConfiguration {
Expand All @@ -95,6 +108,8 @@ fn main() {
},
};

let content = Rc::new(content);

let output = if args.list {
chiritori::list(content, (args.delimiter_start, args.delimiter_end), config)
} else if args.list_all {
Expand Down

0 comments on commit 0edff2a

Please sign in to comment.