Add CLI option for setting binary
All checks were successful
Cargo CI / Build and Test (pull_request) Successful in 1m56s
Cargo CI / Lint (pull_request) Successful in 1m4s

This commit is contained in:
Wojciech Kozlowski 2024-08-24 16:13:45 +02:00
parent 871aeb8436
commit 2784df88bb

View File

@ -40,7 +40,10 @@ struct LibOpt {
#[structopt(long = "ssh", help = "Beets SSH URI")] #[structopt(long = "ssh", help = "Beets SSH URI")]
beets_ssh_uri: Option<OsString>, beets_ssh_uri: Option<OsString>,
#[structopt(long = "beets", help = "Beets config file path")] #[structopt(long = "beets-bin", help = "Beets binary path")]
beets_bin_path: Option<OsString>,
#[structopt(long = "beets-config", help = "Beets config file path")]
beets_config_file_path: Option<OsString>, beets_config_file_path: Option<OsString>,
#[structopt(long = "no-library", help = "Do not connect to the library")] #[structopt(long = "no-library", help = "Do not connect to the library")]
@ -118,13 +121,22 @@ fn with_library(lib_opt: LibOpt, db_opt: DbOpt, builder: MusicHoardBuilder<NoDat
.map(|s| s.into_string()) .map(|s| s.into_string())
.transpose() .transpose()
.expect("failed to extract beets config file path"); .expect("failed to extract beets config file path");
let lib_exec = BeetsLibrarySshExecutor::new(uri) let lib_exec = match lib_opt.beets_bin_path {
Some(beets_bin) => {
let bin = beets_bin.into_string().expect("invalid beets binary path");
BeetsLibrarySshExecutor::bin(uri, bin)
}
None => BeetsLibrarySshExecutor::new(uri),
}
.expect("failed to initialise beets") .expect("failed to initialise beets")
.config(beets_config_file_path); .config(beets_config_file_path);
with_database(db_opt, builder.set_library(BeetsLibrary::new(lib_exec))); with_database(db_opt, builder.set_library(BeetsLibrary::new(lib_exec)));
} else { } else {
let lib_exec = let lib_exec = match lib_opt.beets_bin_path {
BeetsLibraryProcessExecutor::default().config(lib_opt.beets_config_file_path); Some(beets_bin) => BeetsLibraryProcessExecutor::bin(beets_bin),
None => BeetsLibraryProcessExecutor::default(),
}
.config(lib_opt.beets_config_file_path);
with_database(db_opt, builder.set_library(BeetsLibrary::new(lib_exec))); with_database(db_opt, builder.set_library(BeetsLibrary::new(lib_exec)));
} }
} }