use docopt::Docopt;
use java_locator;
const USAGE: &'static str = "
java-locator locates the active Java installation in the host.
Usage:
java-locator
java-locator (-j | --jvmlib)
java-locator (-f | --file) <name>
java-locator (-h | --help)
Options:
-h --help Show this screen.
";
fn main() -> java_locator::errors::Result<()> {
let args = Docopt::new(USAGE)
.and_then(|dopt| dopt.parse())
.unwrap_or_else(|e| e.exit());
if args.find("--jvmlib").unwrap().as_bool() || args.find("-j").unwrap().as_bool() {
java_locator::locate_jvm_dyn_library().map(|s| println!("{}", s))?;
} else if args.find("--file").unwrap().as_bool() || args.find("-f").unwrap().as_bool() {
java_locator::locate_file(args.get_str("<name>")).map(|s| println!("{}", s))?;
} else {
java_locator::locate_java_home().map(|s| println!("{}", s))?;
}
Ok(())
}