diff --git a/.gitignore b/.gitignore index 52a555a..6126be9 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,5 @@ Cargo.lock # Added by cargo /target + +.cargo/ diff --git a/Cargo.toml b/Cargo.toml index bd80fa5..b1b0692 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" [dependencies] anyhow = "1.0.86" -charts-rs = { version = "0.3.11", features = ["image-encoder"] } +charts-rs = { version = "0.3.11" } clap = { version = "4.5.7", features = ["derive"] } console = "0.15.8" csv = "1.3.0" diff --git a/data/lmroman8-regular.ttf b/data/lmroman8-regular.ttf new file mode 100644 index 0000000..2af0b42 Binary files /dev/null and b/data/lmroman8-regular.ttf differ diff --git a/src/graphs.rs b/src/graphs.rs index bffe79a..71c0990 100644 --- a/src/graphs.rs +++ b/src/graphs.rs @@ -1,9 +1,9 @@ //! Export graphs -use charts_rs::{Box, Color, THEME_ANT}; use charts_rs::{get_or_try_init_fonts, RadarChart, RadarIndicator, Series}; -use std::process::Command; +use charts_rs::{Box, Color, THEME_ANT}; use glob::glob; +use std::process::Command; use std::{f32, fs::File, io::Write, iter, sync::LazyLock}; use anyhow::{Context, Result}; @@ -49,12 +49,16 @@ pub(super) fn make_graphs(args: &GraphConfig, _config: &Config) -> Result<()> { /// Delete the existing graphs fn del_graphs(_args: &GraphConfig) -> Result<()> { let mut cmd = Command::new("rm"); - cmd.args(glob("Images/Radar/*.svg")? - .map(|v| v.unwrap().to_str().unwrap().to_string()) - .collect::>()); - cmd.args(glob("Images/Radar/*.png")? - .map(|v| v.unwrap().to_str().unwrap().to_string()) - .collect::>()); + cmd.args( + glob("Images/Radar/*.svg")? + .map(|v| v.unwrap().to_str().unwrap().to_string()) + .collect::>(), + ); + cmd.args( + glob("Images/Radar/*.png")? + .map(|v| v.unwrap().to_str().unwrap().to_string()) + .collect::>(), + ); if let Err(e) = cmd.output() { println!( @@ -79,26 +83,50 @@ fn gen_graph(args: &GraphConfig) -> Result<()> { for graph in csv.values { // println!("{:?} {:#?}", maxv, graph); // let path = format!("{}/{}.png", args.destination, &graph.name); - let path = format!("{}/{}.svg", args.destination, &graph.name); - println!("[INFO] Processing {}",path); + let path_svg = format!("{}/{}.svg", args.destination, &graph.name); + let path_png = format!("{}/{}.png", args.destination, &graph.name); + println!("[INFO] Processing {}", path_svg); - let mut f = File::create(path)?; + let mut f = File::create(&path_svg)?; let mut r = RadarChart::new_with_theme([graph].to_vec(), maxv.to_vec(), THEME_ANT); r.legend_show = Some(false); - r.margin = Box{ left: -90.0, top: -20.0, right: -90.0, bottom: -30.0 }; + r.margin = Box { + left: -90.0, + top: -20.0, + right: -90.0, + bottom: -30.0, + }; r.width = 800.0; r.height = 600.0; r.series_label_font_size = 20.0; - + // r.grid_stroke_color = vec![Color{ r: 75,g: 114, b: 110, a: 0 }]; - r.series_colors = vec![Color{ r: 0,g:127, b:142, a: 255}]; + r.series_colors = vec![Color { + r: 0, + g: 127, + b: 142, + a: 255, + }]; // r.series_colors = vec![Color{ r: 140,g:170, b:161, a: 255}]; // r.series_colors = vec![Color{ r:150,g:251, b:199, a: 255 }]; r.font_family = "LMRoman8".to_string(); - + // f.write_all(&charts_rs::svg_to_png(r.svg().context("Converting to svg")?.as_str())?)?; f.write_all(r.svg().context("Converting to SVG")?.as_bytes())?; + + let mut cmd = Command::new("convert"); + cmd.arg("--size") + .arg("800x600") + .arg(&path_svg) + .arg(path_png); + println!("[INFO] Using convert cli to convert to png"); + if let Err(e) = cmd.output() { + println!( + "[ERRR] An error has occured when converting the file {} to png \n {:#?}", + path_svg, e + ) + } } Ok(()) } diff --git a/src/makepdf.rs b/src/makepdf.rs index 8b2d2c8..73f28ba 100644 --- a/src/makepdf.rs +++ b/src/makepdf.rs @@ -61,6 +61,10 @@ pub(super) struct MakeConfig { /// Wether to add the initial and final context #[arg(short = 'C', long, action = clap::ArgAction::SetFalse)] pub(super) no_context: bool, + + /// Activate shell escape + #[arg(short , long)] + pub(super) shell_escape: bool, } /// Make a pdf spawning a subprocess @@ -110,11 +114,15 @@ async fn launch_subprocess( let last_run = BuildInfo::load(args); let mut built = 0; - let to_build = last_run.lines_parsed; + let mut to_build = last_run.lines_parsed; if args.non_interactive { cmd.arg("--interaction=nonstopmode"); } + if args.shell_escape { + cmd.arg("--shell-escape"); + } + cmd.arg(&rebuild_target.new_name); cmd.env("max_print_line", "3000"); // Specify that we want the command's standard output piped back to us. @@ -158,9 +166,17 @@ async fn launch_subprocess( loop { let res = reader.next_segment().await; - let new = min(built + 1, to_build); + // let new = min(built + 1, to_build); + let new = if built < to_build{ + built+1 + } else{ + to_build +=1; + pb.set_length(to_build); + built+1 + }; built = new; pb.set_position(new); + current_run.lines_parsed += 1; if let Err(e) = res { return Err(anyhow!("[CORE] Runtime error : {}", e)); diff --git a/src/makepdf_structs.rs b/src/makepdf_structs.rs index 2ef7383..de59449 100644 --- a/src/makepdf_structs.rs +++ b/src/makepdf_structs.rs @@ -242,6 +242,7 @@ pub(super) enum LineType { LaTexVersion, /// The write18 mode, whatever that is #[token(" restricted \\write18 enabled.")] + #[token(" \\write18 enabled.")] WriteMode, /// The class of document (book, article, etc)