use anyhow::Result;
use clap::{Parser, Subcommand, ValueEnum};
mod command_last;
mod command_rearrange;
mod command_solvate;
mod command_tip3_to_tip4;
use command_last::command_last;
use command_rearrange::command_rearrange;
use command_solvate::command_solvate;
use command_tip3_to_tip4::command_tip3_to_tip4;
#[derive(Parser)]
#[command(version, about, long_about = None)]
struct Cmd {
#[command(subcommand)]
command: Commands,
}
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
enum SolvateMode {
Distance,
Vdw,
}
#[derive(Subcommand)]
enum Commands {
Last {
#[arg(short, num_args=1..=2, required=true)]
files: Vec<String>,
#[arg(short, default_value = "last.gro")]
outfile: String,
},
Rearrange {
#[arg(short, required = true)]
file: String,
#[arg(short, default_value = "rearranged.gro")]
outfile: String,
#[arg(short, long)]
begin: Vec<String>,
#[arg(short, long)]
end: Vec<String>,
},
Solvate {
#[arg(short, required = true)]
file: String,
#[arg(short, default_value = "rearranged.gro")]
outfile: String,
#[arg(short, long)]
solvent: Option<String>,
#[arg(long)]
exclude: Option<String>,
},
Tip3to4 {
#[arg(short, required = true)]
file: String,
#[arg(short, default_value = "rearranged.gro")]
outfile: String,
}
}
fn main() -> Result<()> {
env_logger::builder()
.format_timestamp(None)
.format_indent(Some(8))
.filter_level(log::LevelFilter::Info)
.init();
let cmd = Cmd::parse();
molar::greeting("molar_bin");
match &cmd.command {
Commands::Last { files, outfile } => {
println!("▶ Action: last");
command_last(files, outfile)?;
},
Commands::Rearrange {
file: infile,
outfile,
begin,
end,
} => {
println!("▶ Action: rearrange");
command_rearrange(infile, outfile, begin, end)?;
},
Commands::Solvate {
file,
outfile,
solvent,
exclude,
} => {
println!("▶ Action: solvate");
command_solvate(file, outfile, solvent, exclude)?;
},
Commands::Tip3to4 { file, outfile } => {
println!("▶ Action: Tip3toTip4");
command_tip3_to_tip4(file, outfile)?;
},
}
Ok(())
}