fix(cli): simplify running the CLI by hiding the maestro init inside the implemtation
All checks were successful
Run Check Script / check (pull_request) Successful in -31s

This commit is contained in:
Ian Letourneau
2025-07-31 15:37:06 -04:00
parent 06aab1f57f
commit 4ac74bc862
9 changed files with 67 additions and 62 deletions

View File

@@ -1,8 +1,10 @@
use clap::Parser;
use clap::builder::ArgPredicate;
use harmony;
use harmony::inventory::Inventory;
use harmony::maestro::Maestro;
use harmony::{score::Score, topology::Topology};
use inquire::Confirm;
use log::debug;
pub mod cli_logger; // FIXME: Don't make me pub
pub mod progress;
@@ -10,7 +12,6 @@ pub mod theme;
#[cfg(feature = "tui")]
use harmony_tui;
use log::debug;
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
@@ -85,6 +86,23 @@ fn list_scores_with_index<T: Topology>(scores_vec: &Vec<Box<dyn Score<T>>>) -> S
return display_str;
}
pub async fn run<T: Topology + Send + Sync + 'static>(
topology: T,
inventory: Inventory,
scores: Vec<Box<dyn Score<T>>>,
args_struct: Option<Args>,
) -> Result<(), Box<dyn std::error::Error>> {
let cli_logger_handle = cli_logger::init();
let mut maestro = Maestro::initialize(inventory, topology).await.unwrap();
maestro.register_all(scores);
let result = init(maestro, args_struct).await;
let _ = tokio::try_join!(cli_logger_handle);
result
}
pub async fn init<T: Topology + Send + Sync + 'static>(
maestro: harmony::maestro::Maestro<T>,
args_struct: Option<Args>,