Add live CLI progress for long-running jobs
This commit is contained in:
@@ -182,18 +182,31 @@ pub fn generate_starter_site_forced(
|
||||
posts: &[PublishedPostSource],
|
||||
language: &str,
|
||||
) -> EngineResult<GenerationReport> {
|
||||
generate_starter_site_with_progress_mode(
|
||||
generate_starter_site_forced_with_progress(
|
||||
conn,
|
||||
output_dir,
|
||||
project_id,
|
||||
metadata,
|
||||
posts,
|
||||
language,
|
||||
true,
|
||||
|_current, _total, _path| {},
|
||||
)
|
||||
}
|
||||
|
||||
pub fn generate_starter_site_forced_with_progress(
|
||||
conn: &Connection,
|
||||
output_dir: &Path,
|
||||
project_id: &str,
|
||||
metadata: &ProjectMetadata,
|
||||
posts: &[PublishedPostSource],
|
||||
language: &str,
|
||||
on_page: impl FnMut(usize, usize, &str),
|
||||
) -> EngineResult<GenerationReport> {
|
||||
generate_starter_site_with_progress_mode(
|
||||
conn, output_dir, project_id, metadata, posts, language, true, on_page,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn generate_starter_site_with_progress(
|
||||
conn: &Connection,
|
||||
output_dir: &Path,
|
||||
@@ -224,8 +237,17 @@ fn generate_starter_site_with_progress_mode(
|
||||
) -> EngineResult<GenerationReport> {
|
||||
let data_dir = project_data_dir(output_dir);
|
||||
let prepared = prepare_site_generation(conn, &data_dir, project_id, metadata, posts)?;
|
||||
let total_pages = GenerationSection::ALL
|
||||
.into_iter()
|
||||
.map(|section| prepared_section_page_count(&prepared, None, section))
|
||||
.sum();
|
||||
let mut current_page = 0;
|
||||
let mut report = GenerationReport::default();
|
||||
for section in GenerationSection::ALL {
|
||||
let mut on_section_page = |_current, _total, path: &str| {
|
||||
current_page += 1;
|
||||
on_page(current_page, total_pages, path);
|
||||
};
|
||||
report.append(render_prepared_site_section_with_progress(
|
||||
conn,
|
||||
output_dir,
|
||||
@@ -234,7 +256,7 @@ fn generate_starter_site_with_progress_mode(
|
||||
section,
|
||||
force,
|
||||
&|_| {},
|
||||
&mut on_page,
|
||||
&mut on_section_page,
|
||||
|| false,
|
||||
)?);
|
||||
}
|
||||
@@ -446,25 +468,61 @@ pub fn apply_validation_sections(
|
||||
posts: &[PublishedPostSource],
|
||||
validation: &SiteValidationReport,
|
||||
sections: &[GenerationSection],
|
||||
) -> EngineResult<GenerationReport> {
|
||||
apply_validation_sections_with_progress(
|
||||
conn,
|
||||
output_dir,
|
||||
project_id,
|
||||
metadata,
|
||||
posts,
|
||||
validation,
|
||||
sections,
|
||||
|_current, _total, _url| {},
|
||||
)
|
||||
}
|
||||
|
||||
#[expect(
|
||||
clippy::too_many_arguments,
|
||||
reason = "validation application adds progress to the existing generation context"
|
||||
)]
|
||||
pub fn apply_validation_sections_with_progress(
|
||||
conn: &Connection,
|
||||
output_dir: &Path,
|
||||
project_id: &str,
|
||||
metadata: &ProjectMetadata,
|
||||
posts: &[PublishedPostSource],
|
||||
validation: &SiteValidationReport,
|
||||
sections: &[GenerationSection],
|
||||
mut on_page: impl FnMut(usize, usize, &str),
|
||||
) -> EngineResult<GenerationReport> {
|
||||
if sections.is_empty() {
|
||||
return Ok(GenerationReport::default());
|
||||
}
|
||||
|
||||
let data_dir = project_data_dir(output_dir);
|
||||
let prepared = prepare_site_generation(conn, &data_dir, project_id, metadata, posts)?;
|
||||
let total_pages = sections
|
||||
.iter()
|
||||
.map(|section| prepared_section_page_count(&prepared, Some(validation), *section))
|
||||
.sum();
|
||||
let mut current_page = 0;
|
||||
let mut report = GenerationReport::default();
|
||||
|
||||
for section in sections {
|
||||
report.append(apply_validation_section_with_progress(
|
||||
let mut on_section_page = |_current, _total, url: &str| {
|
||||
current_page += 1;
|
||||
on_page(current_page, total_pages, url);
|
||||
};
|
||||
report.append(apply_validation_prepared_section_with_progress(
|
||||
conn,
|
||||
output_dir,
|
||||
project_id,
|
||||
metadata,
|
||||
posts,
|
||||
&prepared,
|
||||
validation,
|
||||
*section,
|
||||
|_current, _total, _url| {},
|
||||
|_| {},
|
||||
|| false,
|
||||
&mut on_section_page,
|
||||
&|_| {},
|
||||
&mut || false,
|
||||
)?);
|
||||
}
|
||||
report.append(build_site_search_index(
|
||||
|
||||
Reference in New Issue
Block a user