arcature-cli 2026.1.1

Developer lifecycle CLI for Arcature applications.
Documentation
use std::ffi::OsString;
use std::process::ExitCode;

use super::{CliCommand, parse};
use crate::commands;

/// Parse arguments, execute one Arcature lifecycle command, and return its
/// process exit status.
pub fn run<I, T>(arguments: I) -> ExitCode
where
    I: IntoIterator<Item = T>,
    T: Into<OsString> + Clone,
{
    let command = match parse(arguments) {
        Ok(command) => command,
        Err(error) => {
            let success = error.exit_code() == 0;
            if let Err(print_error) = error.print() {
                eprintln!("error: cannot print command-line diagnostic: {print_error}");
            }
            return if success {
                ExitCode::SUCCESS
            } else {
                ExitCode::FAILURE
            };
        }
    };
    let result = match command {
        CliCommand::New(options) => commands::new::execute(options),
        CliCommand::Install => commands::install::execute(),
        CliCommand::Dev => commands::dev::execute(),
        CliCommand::Build => commands::build::execute(),
        CliCommand::Package(options) => commands::package::execute(options),
        CliCommand::Check(format) => commands::check::execute(format),
        CliCommand::Doctor {
            format,
            checks_only,
        } => commands::doctor::execute(format, checks_only),
        CliCommand::Exposure(format) => commands::exposure::execute(format),
        CliCommand::Routes(format) => commands::routes::execute(format),
        CliCommand::Modules(format) => commands::modules::execute(format),
        CliCommand::Services(format) => commands::services::execute(format),
        CliCommand::Schedule(format) => commands::schedule::execute(format),
        CliCommand::Run { name, arguments } => commands::run_command::execute(&name, &arguments),
        CliCommand::Make(options) => commands::make::execute(options),
        CliCommand::Stubs(cmd) => commands::make::execute_stubs(cmd),
        CliCommand::Script { name, arguments } => commands::script::execute(&name, &arguments),
        CliCommand::Db(cmd) => commands::db::execute(cmd),
        CliCommand::Release(cmd) => commands::release::execute(cmd),
        CliCommand::Inspect(target) => commands::inspect::execute(target),
        CliCommand::Mcp(options) => commands::mcp::execute(options),
    };
    match result {
        Ok(()) => ExitCode::SUCCESS,
        Err(error) => {
            eprintln!("error: {error}");
            ExitCode::FAILURE
        }
    }
}