vestal/cli/src/main.rs
unspeaker b165573e55
Some checks failed
/ build (push) Has been cancelled
update deps and add build infra
2025-04-28 00:57:02 +03:00

33 lines
1.4 KiB
Rust

use std::sync::Arc;
use std::path::PathBuf;
use std::fs::canonicalize;
use clap::{arg, command, value_parser};
use vestal::Module;
/// Define command line arguments.
fn cli () -> clap::Command {
command!()
.arg(arg!([path] "Path to VST DLL").value_parser(value_parser!(PathBuf)))
//.arg(arg!(-s --stub <VALUE> "Provide a stub import").required(false))
.arg(arg!(-i --inspect "Show info, don't run").required(false))
.arg(arg!(-v --verbose "Show a lot of info").required(false))
}
fn main () -> Result<(), Box<dyn std::error::Error>> {
// Parse command line arguments.
let args = cli().get_matches();
if let Some(path) = args.get_one::<PathBuf>("path") {
Module::from_path(path, *(args.get_one::<bool>("verbose").unwrap_or(&false)))
.map(Arc::new)
.unwrap_or_else(|e|panic!("failed to open: {e:?}"))
.search(std::env::current_dir()?)
.search(canonicalize(path.clone().parent().expect("invalid parent path"))?)
.search("/home/user/Lab/Cosmo/wineprefix/drive_c/windows/system32")
.load(true).unwrap_or_else(|e|panic!("failed to load: {e:?}"))
.resolve(true).unwrap_or_else(|e|panic!("failed to resolve: {e:?}"))
.relink().unwrap_or_else(|e|panic!("failed to relink: {e:?}"));
} else {
println!("Pass a path to a VST DLL");
}
Ok(())
}