midas_core/
lib.rs

1pub mod commander;
2pub mod lookup;
3pub mod sequel;
4
5use std::fs;
6use std::path::Path;
7
8use anyhow::{
9  Context as _,
10  Result as AnyhowResult,
11};
12
13use indicatif::ProgressStyle;
14
15/// Ensure the migration state directory exists
16pub fn ensure_migration_state_dir_exists() -> AnyhowResult<()> {
17  let migration_dir = Path::new(".migrations-state");
18
19  // If the directory does not exist, create it
20  // Otherwise, do nothing
21  if !migration_dir.exists() {
22    fs::create_dir_all(migration_dir).context("Failed to create migrations directory")?;
23  }
24
25  Ok(())
26}
27
28/// Setup the progress style
29pub fn progress_style() -> AnyhowResult<ProgressStyle> {
30  let style = ProgressStyle::default_bar()
31    .template("{spinner:.green} [{prefix:.bold.dim}] {wide_msg:.cyan/blue} ")?
32    .tick_chars("⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⦿");
33
34  Ok(style)
35}