arcature-cli 2026.1.0

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::Dev => commands::dev::execute(),
        CliCommand::Build => commands::build::execute(),
        CliCommand::Check(format) => commands::check::execute(format),
        CliCommand::Doctor(format) => commands::doctor::execute(format),
        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::Script { name, arguments } => commands::script::execute(&name, &arguments),
        CliCommand::Db(cmd) => commands::db::execute(cmd),
    };
    match result {
        Ok(()) => ExitCode::SUCCESS,
        Err(error) => {
            eprintln!("error: {error}");
            ExitCode::FAILURE
        }
    }
}