restructured builder code
This commit is contained in:
@@ -2,11 +2,8 @@ use std::process;
|
|||||||
|
|
||||||
use super::Builder;
|
use super::Builder;
|
||||||
|
|
||||||
fn asciidoctor(postfix: &str, in_path: &str, out_path: &str) -> Result<(), String> {
|
fn exec_command(command: &mut process::Command) -> Result<(), String> {
|
||||||
let result = process::Command::new(format!("asciidoctor{postfix}"))
|
let result = command.output();
|
||||||
.arg(format!("{in_path}"))
|
|
||||||
.arg(format!("--out-file={out_path}"))
|
|
||||||
.output();
|
|
||||||
|
|
||||||
if let Ok(success) = result {
|
if let Ok(success) = result {
|
||||||
if success.stderr.len() == 0 {
|
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;
|
pub struct AsciiDoctorDocsBuilder;
|
||||||
|
|
||||||
impl Builder for AsciiDoctorDocsBuilder {
|
impl Builder for AsciiDoctorDocsBuilder {
|
||||||
fn build(&self, in_path: &str, out_path: &str) -> Result<(), String> {
|
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 {
|
impl Builder for AsciiDoctorSlideBuilder {
|
||||||
fn build(&self, in_path: &str, out_path: &str) -> Result<(), String> {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user