cleaned up and fixed a small bug in the display
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
use std::{collections::HashMap, path::Path};
|
use std::{collections::HashMap, path::Path};
|
||||||
|
|
||||||
use crate::app::{
|
use crate::app::{
|
||||||
builder::{asciidoctor::{AsciiDoctorDocsBuilder, AsciiDoctorSlideBuilder}, Builder},
|
builder::{
|
||||||
|
asciidoctor::{AsciiDoctorDocsBuilder, AsciiDoctorSlideBuilder},
|
||||||
|
Builder,
|
||||||
|
},
|
||||||
fs_util,
|
fs_util,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -9,7 +12,7 @@ use super::traits::Command;
|
|||||||
|
|
||||||
pub struct Build {
|
pub struct Build {
|
||||||
slides_builder: Box<dyn Builder>,
|
slides_builder: Box<dyn Builder>,
|
||||||
docs_builder: Box<dyn Builder>
|
docs_builder: Box<dyn Builder>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Command for Build {
|
impl Command for Build {
|
||||||
@@ -27,27 +30,14 @@ impl Command for Build {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (index, path) in paths.iter().enumerate() {
|
for (index, path) in paths.iter().enumerate() {
|
||||||
|
let progress = index + 1;
|
||||||
if path.starts_with("./docs/slides") {
|
if path.starts_with("./docs/slides") {
|
||||||
if self.build_slide(&path).is_ok() {
|
if self.build_slide(&path).is_ok() {
|
||||||
println!(
|
Self::display_status(paths.len(), progress, &path, "slide")
|
||||||
"({} / {}) [{}] {} -> {}",
|
}
|
||||||
index,
|
|
||||||
paths.len(),
|
|
||||||
"slides",
|
|
||||||
path,
|
|
||||||
path.replace(".adoc", ".html")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if self.build_doc(&path).is_ok() {
|
if self.build_doc(&path).is_ok() {
|
||||||
println!(
|
Self::display_status(paths.len(), progress, &path, "doc")
|
||||||
"({} / {}) [{}] {} -> {}",
|
|
||||||
index,
|
|
||||||
paths.len(),
|
|
||||||
"doc",
|
|
||||||
path,
|
|
||||||
path.replace(".adoc", ".html")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,6 +66,17 @@ impl Build {
|
|||||||
return builder.build(&path, &out_path);
|
return builder.build(&path, &out_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn display_status(goal: usize, progress: usize, path: &str, conversion_type: &str) -> () {
|
||||||
|
println!(
|
||||||
|
"({} / {}) [{}] {} -> {}",
|
||||||
|
progress,
|
||||||
|
goal,
|
||||||
|
conversion_type,
|
||||||
|
path,
|
||||||
|
path.replace(".adoc", ".html")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
fn build_doc(&self, path: &str) -> Result<(), String> {
|
fn build_doc(&self, path: &str) -> Result<(), String> {
|
||||||
return self.build_file(&self.docs_builder, path);
|
return self.build_file(&self.docs_builder, path);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user