Add clap and update scripts

This commit is contained in:
stefiosif
2024-09-06 19:05:42 +03:00
parent 0815837cd5
commit 2081ddac56
6 changed files with 275 additions and 20 deletions

View File

@@ -6,20 +6,31 @@ mod interface;
mod movegen;
mod search;
use clap::{Parser, ValueEnum};
use interface::uci;
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
#[arg(short, long)]
mode: Mode,
}
#[derive(ValueEnum, Debug, Clone, Copy)]
pub enum Mode {
Perft,
Uci,
}
fn main() {
movegen::attack::init_attacks();
let command = std::env::args().nth(1).unwrap_or(String::from("quit"));
match command.as_str() {
"perft" => search::perft::perftree_script(),
"uci" => {
match Args::parse().mode {
Mode::Perft => search::perft::perftree_script(),
Mode::Uci => {
let input = io::stdin().lock();
let output = io::stdout().lock();
uci::uci_loop(input, output).unwrap_or_else(|e| println!("{}", e));
}
"quit" => println!("Exiting.."),
_ => println!("Wrong command. Exiting.."),
};
}
}