Resolve "Local collection trait and beets implementation" #9
@ -78,32 +78,6 @@ pub struct Beets {
|
||||
executor: Box<dyn BeetsExecutor>,
|
||||
}
|
||||
|
||||
pub struct SystemExecutor {
|
||||
bin: String,
|
||||
}
|
||||
|
||||
impl SystemExecutor {
|
||||
pub fn new(bin: &str) -> SystemExecutor {
|
||||
SystemExecutor {
|
||||
bin: bin.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for SystemExecutor {
|
||||
fn default() -> Self {
|
||||
SystemExecutor::new("beet")
|
||||
}
|
||||
}
|
||||
|
||||
impl BeetsExecutor for SystemExecutor {
|
||||
fn exec(&mut self, arguments: Vec<String>) -> Result<Vec<String>, Error> {
|
||||
let output = Command::new(&self.bin).args(arguments).output()?;
|
||||
let output = std::str::from_utf8(&output.stdout)?;
|
||||
Ok(output.split('\n').map(|s| s.to_string()).collect())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Hash, Eq, PartialEq)]
|
||||
struct AlbumId {
|
||||
artist: String,
|
||||
@ -206,6 +180,32 @@ impl Library for Beets {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SystemExecutor {
|
||||
bin: String,
|
||||
}
|
||||
|
||||
impl SystemExecutor {
|
||||
pub fn new(bin: &str) -> SystemExecutor {
|
||||
SystemExecutor {
|
||||
bin: bin.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for SystemExecutor {
|
||||
fn default() -> Self {
|
||||
SystemExecutor::new("beet")
|
||||
}
|
||||
}
|
||||
|
||||
impl BeetsExecutor for SystemExecutor {
|
||||
fn exec(&mut self, arguments: Vec<String>) -> Result<Vec<String>, Error> {
|
||||
let output = Command::new(&self.bin).args(arguments).output()?;
|
||||
let output = std::str::from_utf8(&output.stdout)?;
|
||||
Ok(output.split('\n').map(|s| s.to_string()).collect())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
Loading…
Reference in New Issue
Block a user