Fixes some of the jank #10
|
|
@ -16,7 +16,9 @@ use clap::Args;
|
|||
use std::process::Stdio;
|
||||
|
||||
use crate::makepdf_functions::{make_clean, make_file, make_glossaries, make_list};
|
||||
use crate::makepdf_misc::{BLOCK_PROGRESSION, HELP_BLOCK_SELECTION, HELP_VERBOSITY_LEVEL};
|
||||
use crate::makepdf_misc::{
|
||||
BLOCK_PROGRESSION, HELP_BLOCK_SELECTION, HELP_BUILD_TARGET_LIST, HELP_VERBOSITY_LEVEL,
|
||||
};
|
||||
use crate::makepdf_structs::{
|
||||
BuildInfo, LineType, MakeTargets, Status, VerboseLevel, COL_NORMAL, TXT_BOXX, TXT_CNTX,
|
||||
TXT_CRIT, TXT_ERRR, TXT_INFO, TXT_MISC, TXT_UKNW, TXT_WARN,
|
||||
|
|
@ -31,7 +33,7 @@ pub(crate) struct MakeConfig {
|
|||
pub(crate) filename: String,
|
||||
|
||||
/// Special target
|
||||
#[arg(short, long)]
|
||||
#[arg(short, long, help = format!("Build with a special target. {}", HELP_BUILD_TARGET_LIST.as_str()))]
|
||||
pub(crate) target: Option<MakeTargets>,
|
||||
|
||||
/// The verbosity level
|
||||
|
|
|
|||
|
|
@ -11,7 +11,10 @@ use std::{
|
|||
use anyhow::Result;
|
||||
use regex::Regex;
|
||||
|
||||
use crate::makepdf::MakeConfig;
|
||||
use crate::{
|
||||
makepdf::MakeConfig,
|
||||
makepdf_structs::{COL_ERROR, COL_INFO, COL_MISC, COL_WARNING},
|
||||
};
|
||||
|
||||
/// Regex detecting wether an input line is present
|
||||
static INPUT_REGEX: LazyLock<Regex> =
|
||||
|
|
@ -26,18 +29,28 @@ pub(crate) fn make_file(args: &MakeConfig) -> String {
|
|||
let mut contents = String::new();
|
||||
|
||||
// Warn about wrong keys
|
||||
// clear_keys(&mut args);
|
||||
clear_keys(args, &m);
|
||||
|
||||
f.read_to_string(&mut contents).unwrap();
|
||||
for line in contents.lines() {
|
||||
if let Some(c) = INPUT_REGEX.captures(line) {
|
||||
// Check wether it should be added
|
||||
if add_checker(&c[1], &m, args) {
|
||||
println!("[PREP] Including {}", &c[1]);
|
||||
println!(
|
||||
"{} {} {}",
|
||||
COL_INFO.apply_to("[PREP]"),
|
||||
COL_MISC.apply_to("Including"),
|
||||
&c[1]
|
||||
);
|
||||
of.write_all(line.as_bytes()).unwrap();
|
||||
of.write_all("\n".as_bytes()).unwrap();
|
||||
} else {
|
||||
println!("[PREP] Excluding {}", &c[1]);
|
||||
println!(
|
||||
"{} {} {}",
|
||||
COL_INFO.apply_to("[PREP]"),
|
||||
COL_WARNING.apply_to("Excluding"),
|
||||
&c[1]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
of.write_all(line.as_bytes()).unwrap();
|
||||
|
|
@ -47,11 +60,29 @@ pub(crate) fn make_file(args: &MakeConfig) -> String {
|
|||
format!("{:?}", &path)
|
||||
}
|
||||
|
||||
// fn clear_keys(args: &mut &MakeConfig) -> _ {
|
||||
// for k in args.only{
|
||||
// if
|
||||
// }
|
||||
// }
|
||||
/// Clear the list of keys (for now only warn)
|
||||
fn clear_keys(args: &MakeConfig, dict_entries: &HashMap<String, String>) {
|
||||
for k in args.only.iter() {
|
||||
if !dict_entries.contains_key(k) {
|
||||
panic!(
|
||||
"{} The key {} wasn't in the list of togglable imports {:?} rerun with option -t list for the full list",
|
||||
COL_ERROR.apply_to("[ERRR]"),
|
||||
k,
|
||||
dict_entries.keys()
|
||||
)
|
||||
}
|
||||
}
|
||||
for k in args.no.iter() {
|
||||
if !dict_entries.contains_key(k) {
|
||||
panic!(
|
||||
"{} The key {} wasn't in the list of togglable imports {:?} rerun with option -t list for the full list",
|
||||
COL_ERROR.apply_to("[ERRR]"),
|
||||
k,
|
||||
dict_entries.keys()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Algorithm to check wether to add or not the entry
|
||||
fn add_checker(check: &str, dict_entries: &HashMap<String, String>, args: &MakeConfig) -> bool {
|
||||
|
|
|
|||
Loading…
Reference in New Issue