Skip to main content

paigasus_helikon_cli/
lib.rs

1//! Internal implementation of the `helikon` / `paigasus-helikon` CLI.
2//!
3//! **Internal — no stability guarantees.** This library target exists so
4//! the two binaries can share code; its API may change in any release.
5
6pub mod cli;
7pub mod eval_cmd;
8pub mod mcp_cmd;
9pub mod model;
10pub mod registry;
11pub mod repl;
12pub mod rhai_tool;
13pub mod sidecar;
14
15use clap::Parser as _;
16use std::process::ExitCode;
17
18/// Entry point shared by both binaries.
19pub fn main() -> ExitCode {
20    let cli = cli::Cli::parse();
21    let runtime = match tokio::runtime::Runtime::new() {
22        Ok(rt) => rt,
23        Err(e) => {
24            eprintln!("failed to start runtime: {e}");
25            return ExitCode::FAILURE;
26        }
27    };
28    match runtime.block_on(run(cli)) {
29        Ok(code) => code,
30        Err(e) => {
31            eprintln!("error: {e:#}");
32            ExitCode::FAILURE
33        }
34    }
35}
36
37async fn run(cli: cli::Cli) -> anyhow::Result<ExitCode> {
38    match cli.command {
39        cli::Command::Repl(args) => repl::run(args).await,
40        cli::Command::Eval { command } => match command {
41            cli::EvalCommand::Run(args) => eval_cmd::run(args).await,
42        },
43        cli::Command::Mcp { command } => match command {
44            cli::McpCommand::Serve(args) => mcp_cmd::serve(args).await,
45        },
46    }
47}