Add CLI option for setting binary #184

Merged
wojtek merged 1 commits from 183---allow-the-setting-of-a-custom-binary-path-for-beets into main 2024-08-24 23:11:00 +02:00

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 {
.expect("failed to initialise beets") Some(beets_bin) => {
.config(beets_config_file_path); let bin = beets_bin.into_string().expect("invalid beets binary path");
BeetsLibrarySshExecutor::bin(uri, bin)
}
None => BeetsLibrarySshExecutor::new(uri),
}
.expect("failed to initialise beets")
.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)));
} }
} }