use std::process::ExitCode;
use clap::{CommandFactory, Parser, Subcommand};
mod commands {
pub mod build;
pub mod completions;
pub mod eventb_io;
pub mod export;
pub mod fmt;
pub mod import;
pub mod sarif;
pub mod validate;
}
#[derive(Parser)]
#[command(
name = "rossi",
version,
propagate_version = true,
about = "Rossi command-line tools for Event-B models"
)]
struct Cli {
#[command(subcommand)]
command: Command,
}
#[derive(Subcommand)]
enum Command {
#[command(about = "Validate Event-B model files")]
Validate(commands::validate::ValidateArgs),
#[command(about = "Import Rodin archives into Event-B text")]
Import(commands::import::ImportArgs),
#[command(about = "Export Event-B text into a Rodin .zip archive")]
Export(commands::export::ExportArgs),
#[command(about = "Reformat Event-B text/archives in place")]
Fmt(commands::fmt::FmtArgs),
#[command(about = "Static-check a Rodin project and emit .bcc/.bcm output")]
Build(commands::build::BuildArgs),
#[command(about = "Run the Rossi language server over stdio")]
Lsp,
#[command(about = "Generate a shell completion script")]
Completions(commands::completions::CompletionsArgs),
}
fn main() -> ExitCode {
match Cli::parse().command {
Command::Validate(args) => commands::validate::run(args),
Command::Import(args) => commands::import::run(args),
Command::Export(args) => commands::export::run(args),
Command::Fmt(args) => commands::fmt::run(args),
Command::Build(args) => commands::build::run_build_command(args),
Command::Lsp => match eventb_lsp::run_stdio_blocking() {
Ok(()) => ExitCode::SUCCESS,
Err(e) => {
eprintln!("rossi lsp: {e}");
ExitCode::from(1)
}
},
Command::Completions(args) => commands::completions::run(args, &mut Cli::command()),
}
}