use smart_markdown::Markdown;
use std::io::{self, Write};
use std::thread;
use std::time::Duration;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut md = Markdown::parse(
"## Build Pipeline\n\n\
| Task | Status | Details |\n\
|---------|---------|---------------------------------|\n\
| build | pending | |\n\
| test | pending | |\n\
| deploy | pending | |\n\
\n\
_Live streaming table update demo_\n\n\
\n\
### Task Status\n\n\
- [x] Compile source\n\
- [x] Run unit tests\n\
- [ ] Integration tests\n\
- [ ] Deploy to staging\n\
\n\
See the pipeline logs or visit <https://ci.example.com>\n\
for detailed build output.\n"
);
println!("\nStreaming Markdown Demo\n-----------------------\n");
md.render();
io::stdout().flush()?;
thread::sleep(Duration::from_millis(800));
md.append_to_cell(0, 2, "compiling source");
md.render();
io::stdout().flush()?;
thread::sleep(Duration::from_millis(800));
md.append_to_cell(0, 2, " files...");
md.render();
io::stdout().flush()?;
thread::sleep(Duration::from_millis(800));
md.append_to_cell(1, 2, "running unit tests across all crates");
md.render();
io::stdout().flush()?;
thread::sleep(Duration::from_millis(800));
md.set_cell_content(0, 1, "done");
md.render();
io::stdout().flush()?;
thread::sleep(Duration::from_millis(800));
md.set_cell_content(1, 1, "running");
md.append_to_cell(1, 2, " with coverage instrumentation enabled for llvm-cov");
md.render();
io::stdout().flush()?;
thread::sleep(Duration::from_millis(1200));
md.set_cell_content(2, 1, "queued");
md.append_to_cell(0, 2, " and linking final binary artifact");
md.render();
io::stdout().flush()?;
thread::sleep(Duration::from_millis(800));
md.set_cell_content(2, 1, "done");
md.set_cell_content(2, 2, "release published to registry");
md.render();
io::stdout().flush()?;
thread::sleep(Duration::from_millis(800));
println!();
Ok(())
}