Rename beets command executor
This commit is contained in:
parent
a5c1bb8558
commit
575b30e454
@ -95,7 +95,7 @@ trait LibraryPrivate {
|
||||
}
|
||||
|
||||
impl<BLE: BeetsLibraryExecutor> BeetsLibrary<BLE> {
|
||||
/// Create a new beets library with the provided executor, e.g. [`BeetsLibraryCommandExecutor`].
|
||||
/// Create a new beets library with the provided executor, e.g. [`BeetsLibraryProcessExecutor`].
|
||||
pub fn new(executor: BLE) -> Self {
|
||||
BeetsLibrary { executor }
|
||||
}
|
||||
@ -199,15 +199,15 @@ impl<BLE: BeetsLibraryExecutor> LibraryPrivate for BeetsLibrary<BLE> {
|
||||
}
|
||||
|
||||
/// Beets library executor that executes beets commands in their own process.
|
||||
pub struct BeetsLibraryCommandExecutor {
|
||||
pub struct BeetsLibraryProcessExecutor {
|
||||
bin: OsString,
|
||||
config: Option<PathBuf>,
|
||||
}
|
||||
|
||||
impl BeetsLibraryCommandExecutor {
|
||||
/// Create a new [`BeetsLibraryCommandExecutor`] that uses the provided beets executable.
|
||||
impl BeetsLibraryProcessExecutor {
|
||||
/// Create a new [`BeetsLibraryProcessExecutor`] that uses the provided beets executable.
|
||||
pub fn new<S: Into<OsString>>(bin: S) -> Self {
|
||||
BeetsLibraryCommandExecutor {
|
||||
BeetsLibraryProcessExecutor {
|
||||
bin: bin.into(),
|
||||
config: None,
|
||||
}
|
||||
@ -220,14 +220,14 @@ impl BeetsLibraryCommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for BeetsLibraryCommandExecutor {
|
||||
/// Create a new [`BeetsLibraryCommandExecutor`] that uses the system's default beets executable.
|
||||
impl Default for BeetsLibraryProcessExecutor {
|
||||
/// Create a new [`BeetsLibraryProcessExecutor`] that uses the system's default beets executable.
|
||||
fn default() -> Self {
|
||||
BeetsLibraryCommandExecutor::new("beet")
|
||||
BeetsLibraryProcessExecutor::new("beet")
|
||||
}
|
||||
}
|
||||
|
||||
impl BeetsLibraryExecutor for BeetsLibraryCommandExecutor {
|
||||
impl BeetsLibraryExecutor for BeetsLibraryProcessExecutor {
|
||||
fn exec<S: AsRef<str> + 'static>(&mut self, arguments: &[S]) -> Result<Vec<String>, Error> {
|
||||
let mut cmd = Command::new(&self.bin);
|
||||
if let Some(ref path) = self.config {
|
||||
|
@ -8,7 +8,7 @@ use structopt::StructOpt;
|
||||
use musichoard::{
|
||||
collection::MhCollectionManager,
|
||||
database::json::{JsonDatabase, JsonDatabaseFileBackend},
|
||||
library::beets::{BeetsLibrary, BeetsLibraryCommandExecutor},
|
||||
library::beets::{BeetsLibrary, BeetsLibraryProcessExecutor},
|
||||
};
|
||||
|
||||
mod tui;
|
||||
@ -42,7 +42,7 @@ fn main() {
|
||||
let opt = Opt::from_args();
|
||||
|
||||
let beets = BeetsLibrary::new(
|
||||
BeetsLibraryCommandExecutor::default().config(opt.beets_config_file_path.as_deref()),
|
||||
BeetsLibraryProcessExecutor::default().config(opt.beets_config_file_path.as_deref()),
|
||||
);
|
||||
|
||||
let database = JsonDatabase::new(JsonDatabaseFileBackend::new(&opt.database_file_path));
|
||||
|
@ -8,7 +8,7 @@ use once_cell::sync::Lazy;
|
||||
|
||||
use musichoard::{
|
||||
library::{
|
||||
beets::{BeetsLibrary, BeetsLibraryCommandExecutor},
|
||||
beets::{BeetsLibrary, BeetsLibraryProcessExecutor},
|
||||
Field, Library, Query,
|
||||
},
|
||||
Artist,
|
||||
@ -16,17 +16,17 @@ use musichoard::{
|
||||
|
||||
use crate::COLLECTION;
|
||||
|
||||
static BEETS_EMPTY_CONFIG: Lazy<Arc<Mutex<BeetsLibrary<BeetsLibraryCommandExecutor>>>> =
|
||||
static BEETS_EMPTY_CONFIG: Lazy<Arc<Mutex<BeetsLibrary<BeetsLibraryProcessExecutor>>>> =
|
||||
Lazy::new(|| {
|
||||
Arc::new(Mutex::new(BeetsLibrary::new(
|
||||
BeetsLibraryCommandExecutor::default(),
|
||||
BeetsLibraryProcessExecutor::default(),
|
||||
)))
|
||||
});
|
||||
|
||||
static BEETS_TEST_CONFIG: Lazy<Arc<Mutex<BeetsLibrary<BeetsLibraryCommandExecutor>>>> =
|
||||
static BEETS_TEST_CONFIG: Lazy<Arc<Mutex<BeetsLibrary<BeetsLibraryProcessExecutor>>>> =
|
||||
Lazy::new(|| {
|
||||
Arc::new(Mutex::new(BeetsLibrary::new(
|
||||
BeetsLibraryCommandExecutor::default().config(Some(
|
||||
BeetsLibraryProcessExecutor::default().config(Some(
|
||||
&fs::canonicalize("./tests/files/library/config.yml").unwrap(),
|
||||
)),
|
||||
)))
|
||||
@ -45,7 +45,7 @@ fn test_no_config_list() {
|
||||
|
||||
#[test]
|
||||
fn test_invalid_config() {
|
||||
let mut beets = BeetsLibrary::new(BeetsLibraryCommandExecutor::default().config(Some(
|
||||
let mut beets = BeetsLibrary::new(BeetsLibraryProcessExecutor::default().config(Some(
|
||||
&PathBuf::from("./tests/files/library/config-does-not-exist.yml"),
|
||||
)));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user