use std::process::ExitCode;
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(
name = "mesofact",
version,
about = "mesofact — Rust-native web framework runtime",
long_about = "Scaffold a new project, serve a built bundle or host SSR routes, \
run the Mode-2 proxy, or publish a dist/ tree.\n\n\
This is the production binary: no file watcher, no bundler, no dev \
storage surface. For the hot-reload dev loop — and for a single CLI \
that also carries these verbs — use `mes`, which is a superset of \
this one in the dev direction."
)]
struct Cli {
#[command(subcommand)]
command: Command,
}
#[derive(Subcommand)]
enum Command {
New(mesofact::cli::new::NewArgs),
Serve(mesofact::cli::serve::ServeArgs),
Proxy(Box<mesofact::core::proxy::config::Config>),
#[cfg(feature = "publish")]
Publish(mesofact::cli::publish::PublishArgs),
Selfcheck(mesofact::cli::selfcheck::SelfcheckArgs),
}
#[tokio::main]
async fn main() -> ExitCode {
let cli = Cli::parse();
match cli.command {
Command::New(args) => to_exit_code(mesofact::cli::new::run(args)),
Command::Serve(args) => to_exit_code(mesofact::cli::serve::run(args).await),
Command::Proxy(cfg) => to_exit_code(mesofact::cli::proxy::run(*cfg).await),
#[cfg(feature = "publish")]
Command::Publish(args) => mesofact::cli::publish::run(args).await,
Command::Selfcheck(args) => to_exit_code(mesofact::cli::selfcheck::run(args)),
}
}
fn to_exit_code(result: anyhow::Result<()>) -> ExitCode {
match result {
Ok(()) => ExitCode::SUCCESS,
Err(err) => {
eprintln!("mesofact: {err:#}");
ExitCode::FAILURE
}
}
}