Make cli async so running the graph works, add schema generation to readme
Some checks failed
test / test (push) Failing after 47m44s

This commit is contained in:
2025-12-17 17:09:05 +10:30
parent 3d4f327b66
commit 4da6d64988
3 changed files with 21 additions and 12 deletions

View File

@@ -7,6 +7,12 @@ A super fast, simple base for building analytics applications.
A basic CLI is available to run a graph and a subset of analytics workloads.
In development environments, use `cargo run --bin cli -- -h` for more information.
### Generating the JSON schema:
`cargo run --bin cli -- generate-schema`
The schema will be written to a schema.json file.
## General Notes
Setting the number of threads in overhead allocation: set RAYON_NUM_THREADS environment

View File

@@ -1,8 +1,9 @@
use clap::Parser;
use coster_rs::cli::Cli;
fn main() -> anyhow::Result<()> {
#[tokio::main]
async fn main() -> anyhow::Result<()> {
env_logger::init();
let cli = Cli::parse();
cli.run()
cli.run().await
}

View File

@@ -7,7 +7,7 @@ use std::{
use std::io::Write;
use clap::{command, Parser};
use clap::Parser;
pub use commands::Commands;
@@ -23,17 +23,17 @@ use crate::{
mod commands;
#[derive(Parser)]
#[command(name = "coster-rs")]
#[command(author = "Pivato M. <mpivato4@gmail.com>")]
#[command(name = "ingey")]
#[command(author = "Pivato M. <contact@michaelpivato.dev>")]
#[command(version = "0.0.1")]
#[command(about = "Simple, fast, efficient costing tool", long_about = None)]
#[command(about = "Simple, fast, efficient data manipulation tool", long_about = None)]
pub struct Cli {
#[clap(subcommand)]
pub command: Commands,
}
impl Cli {
pub fn run(self) -> anyhow::Result<()> {
pub async fn run(self) -> anyhow::Result<()> {
match self.command {
Commands::MoveMoney {
rules,
@@ -174,11 +174,13 @@ impl Cli {
let reader = BufReader::new(file);
let graph = serde_json::from_reader(reader)?;
let graph = RunnableGraph::from_graph(graph);
// TODO: Possible to await here? Actually needs awaiting to work
graph.run_default_tasks(threads, |id, status| {
info!("Node with id {} finished with status {:?}", id, status)
});
Ok(())
let result = graph
.run_default_tasks(threads, |id, status| {
info!("Node with id {} finished with status {:?}", id, status)
})
.await;
result
}
Commands::GenerateSchema { output } => {
let schema = schema_for!(Graph);