Skip to main content

sql_fun_cli/
lib.rs

1#![deny(missing_docs)]
2//! sql-fun cli binary louncher
3mod child_proc;
4mod docker;
5mod init;
6mod runnable;
7
8use self::init::initialize;
9use ::sql_fun_core::{CliSubCommand, SqlFunArgs};
10use std::process::ExitCode;
11
12pub use self::runnable::{RunableCommand, StdStream};
13
14#[cfg(test)]
15/// Test helpers for the sql-fun CLI crate.
16pub mod test_helpers;
17
18/// Runs builtin CLI subcommands
19///
20/// # Errors
21///
22/// Returns an error if executing the chosen subcommand fails.
23pub async fn run_builtin(args: &SqlFunArgs) -> Result<ExitCode, anyhow::Error> {
24    let Some(sub_command) = args.command() else {
25        eprintln!("no sub-command specified");
26        return Ok(ExitCode::SUCCESS);
27    };
28    match sub_command {
29        CliSubCommand::Initialize(init_args) => Ok(initialize(args, init_args).await?),
30        _ => unreachable!(),
31    }
32}