mod breakpoint_host;
mod check;
mod color_mode;
mod debug_mode;
mod diagnostic_render;
mod exit_code;
mod run;
mod source_file;
use anyhow::Result;
use clap::{Parser, Subcommand};
pub use color_mode::ColorMode;
pub use debug_mode::DebugMode;
#[derive(Parser, Debug)]
#[command(
name = "praxis",
version,
about = "The Praxis programming language compiler and tools.",
long_about = "Praxis is a small, statically typed, garbage-collected language for \
Advent of Code-style puzzle solving.\n\n\
Homepage: https://github.com/tljubej/praxis"
)]
struct Cli {
#[arg(long, default_value = "auto", global = true)]
color: ColorMode,
#[command(subcommand)]
command: Command,
}
#[derive(Subcommand, Debug)]
enum Command {
Run {
file: String,
#[arg(long)]
input: Option<String>,
#[arg(long, default_value = "auto")]
debug: DebugMode,
},
Check {
file: String,
},
Lsp {
#[arg(long)]
stdio: bool,
},
}
fn main() -> Result<()> {
let cli = Cli::parse();
praxis_runtime::assert_abi_version();
let exit = match cli.command {
Command::Check { file } => check::run(&file, cli.color),
Command::Run { file, input, debug } => run::run(&file, input.as_deref(), debug, cli.color),
Command::Lsp { stdio: _ } => praxis_lsp::run(),
}?;
std::process::exit(exit);
}