Skip to content

Commit

Permalink
Cleaning up main.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
2AUK committed Nov 7, 2023
1 parent 619dd3c commit 832a49e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 41 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ Currently, the calculator is focused for command-line usage with a very minimal
This will change soon with bindings in both Rust and Python.

The command-line tool can be called with:

`rism [OPTIONS] <input_file.toml>`

The list of options:
Expand Down
56 changes: 16 additions & 40 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use librism::{
io::writer::RISMWriter,
thermodynamics::thermo::{SFEs, TDDriver},
};
use ndarray::{Array, Array2};
use std::path::PathBuf;

struct Args {
Expand All @@ -15,6 +14,19 @@ struct Args {
compress: Compress,
}

fn print_usage_instructions() {
println!("Usage: rism [OPTIONS] <inputfile.toml>\n");
println!("\tRuns the RISM solver and solves the problem defined in <inputfile.toml>\n");
println!("Options:");
println!(" [-h|--help] Show this help message");
println!(" [-c|--compress] Compress the solvent-solvent problem for future use");
println!(" Verbosity:");
println!(" [-q|--quiet] Suppress all output from solver (DEFAULT)");
println!(" [-v|--verbose] Print basic information from solver");
println!(" [-l|--loud] Print all information from solver");
std::process::exit(0);
}

fn parse_args() -> Result<Args, lexopt::Error> {
use lexopt::prelude::*;

Expand All @@ -28,27 +40,15 @@ fn parse_args() -> Result<Args, lexopt::Error> {
Short('v') | Long("verbose") => verbosity = Verbosity::Verbose,
Short('l') | Long("loud") => verbosity = Verbosity::VeryVerbose,
Short('c') | Long("compress") => compress = Compress::Compress,
Short('h') | Long("help") => {
println!("Usage: rism [OPTIONS] <inputfile.toml>\n");
println!(
"\tRuns the RISM solver and solves the problem defined in <inputfile.toml>i\n"
);
println!("Options:");
println!(" [-h|--help]\tShow this help message");
println!(" [-c|--compress]\tCompress the solvent-solvent problem for future use");
println!(" Verbosity:");
println!(" [-q|--quiet]\tSuppress all output from solver (DEFAULT)");
println!(" [-v|--verbose]\tPrint basic information from solver");
println!(" [-l|--loud]\tPrint all information from solver");
std::process::exit(0);
}
Short('h') | Long("help") => print_usage_instructions(),

Value(val) => input_file = Some(val.into()),
_ => return Err(arg.unexpected()),
}
}

Ok(Args {
input_file: input_file.ok_or("Missing input file")?,
input_file: input_file.ok_or("Missing input file. Use `rism -h` to see usage.")?,
verbosity,
compress,
})
Expand All @@ -58,30 +58,6 @@ fn main() -> Result<(), lexopt::Error> {
#[cfg(feature = "dhat-on")]
let _dhat = dhat::Profiler::new_heap();
let args = parse_args()?;
// let mut driver = RISMDriver::from_toml(&args.input_file);
// let solutions = driver.execute(args.verbosity, args.compress);
//
// let wv = driver.solvent.borrow().wk.clone();
// let wu = {
// match driver.solute {
// Some(v) => Some(v.borrow().wk.clone()),
// None => None,
// }
// };
// let td = TDDriver::new(&solutions, wv, wu);
// let thermo = td.execute();
// let writer = RISMWriter::new(
// &args
// .input_file
// .file_stem()
// .unwrap()
// .to_str()
// .unwrap()
// .to_string(),
// &solutions,
// &thermo,
// );
//writer.write().unwrap();
Calculator::new(args.input_file, args.verbosity, args.compress).execute();
Ok(())
}

0 comments on commit 832a49e

Please sign in to comment.