Add CLI option for setting binary (#184)
All checks were successful
Cargo CI / Build and Test (push) Successful in 1m57s
Cargo CI / Lint (push) Successful in 1m3s
Cargo CI / Build and Test (pull_request) Successful in 1m54s
Cargo CI / Lint (pull_request) Successful in 1m3s

Closes #183

Reviewed-on: #184
This commit is contained in:
Wojciech Kozlowski 2024-08-24 23:10:59 +02:00
parent 871aeb8436
commit d8fd952456

View File

@ -40,7 +40,10 @@ struct LibOpt {
#[structopt(long = "ssh", help = "Beets SSH URI")]
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>,
#[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())
.transpose()
.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")
.config(beets_config_file_path);
with_database(db_opt, builder.set_library(BeetsLibrary::new(lib_exec)));
} else {
let lib_exec =
BeetsLibraryProcessExecutor::default().config(lib_opt.beets_config_file_path);
let lib_exec = match lib_opt.beets_bin_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)));
}
}