diff --git a/src/app/builder/asciidoctor.rs b/src/app/builder/asciidoctor.rs index dd5d51a..d235848 100644 --- a/src/app/builder/asciidoctor.rs +++ b/src/app/builder/asciidoctor.rs @@ -2,11 +2,8 @@ use std::process; use super::Builder; -fn asciidoctor(postfix: &str, in_path: &str, out_path: &str) -> Result<(), String> { - let result = process::Command::new(format!("asciidoctor{postfix}")) - .arg(format!("{in_path}")) - .arg(format!("--out-file={out_path}")) - .output(); +fn exec_command(command: &mut process::Command) -> Result<(), String> { + let result = command.output(); if let Ok(success) = result { if success.stderr.len() == 0 { @@ -20,11 +17,39 @@ fn asciidoctor(postfix: &str, in_path: &str, out_path: &str) -> Result<(), Strin } } +fn asciidoctor_docs(in_path: &str, out_path: &str) -> process::Command { + let mut command = process::Command::new(format!("asciidoctor")); + + command + .arg(format!("{in_path}")) + .arg(format!("--out-file={out_path}")); + + return command; +} + +fn asciidoctor_slides(in_path: &str, out_path: &str) -> process::Command { + let mut command = process::Command::new(format!("asciidoctor-revealjs-linux")); + let revealjs_path = path_between(out_path, "./dist/slides/revealjs"); + + command + .arg(format!("{in_path}")) + .arg(format!("--out-file={out_path}")); + + return command; +} + +fn path_between(from: &str, to: &str) -> &str { + let from_segments = from.split("/"); + let to_segments = to.split("/"); + let last_common +} + pub struct AsciiDoctorDocsBuilder; impl Builder for AsciiDoctorDocsBuilder { fn build(&self, in_path: &str, out_path: &str) -> Result<(), String> { - return asciidoctor("", in_path, out_path); + let mut command = asciidoctor_docs(in_path, out_path); + return exec_command(&mut command); } } @@ -41,6 +66,7 @@ pub struct AsciiDoctorSlideBuilder; impl Builder for AsciiDoctorSlideBuilder { fn build(&self, in_path: &str, out_path: &str) -> Result<(), String> { - return asciidoctor("-revealjs-linux", in_path, out_path); + let mut command = asciidoctor_slides(in_path, out_path); + return exec_command(&mut command); } }