use clap::{Parser as ClapParser, Subcommand};
#[derive(ClapParser, Debug)]
#[command(name = "ternlang", version, about, long_about = None)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand, Debug)]
enum Commands {
Run {
path: String,
#[arg(short, long, default_value_t = 10_000_000)]
max_steps: u64,
},
Build {
input: String,
#[arg(short, long)]
output: Option<String>,
},
Sim {
path: String,
},
Fmt {
files: Vec<String>,
},
Repl,
Compat {
input: String,
output: String,
},
}
fn main() {
let cli = Cli::parse();
match cli.command {
Commands::Run { path, max_steps } => {
println!("Running {} (max_steps={})", path, max_steps);
}
Commands::Build { input, output } => {
let out = output.unwrap_or_else(|| format!("{}.ternbc", input));
println!("Building {} -> {}", input, out);
}
Commands::Sim { path } => {
println!("Simulating {}", path);
}
Commands::Fmt { files } => {
if files.is_empty() {
println!("Formatting stdin...");
} else {
println!("Formatting {} file(s)", files.len());
}
}
Commands::Repl => {
println!("ternlang REPL — type :quit to exit");
}
Commands::Compat { input, output } => {
println!("Converting {} -> {}", input, output);
}
}
}