Create the main binary #15
@ -1,6 +1,6 @@
|
|||||||
//! Module for interacting with the music library.
|
//! Module for interacting with the music library.
|
||||||
|
|
||||||
use std::{fmt, num::ParseIntError, str::Utf8Error};
|
use std::{num::ParseIntError, str::Utf8Error};
|
||||||
|
|
||||||
use crate::Artist;
|
use crate::Artist;
|
||||||
|
|
||||||
@ -128,12 +128,6 @@ impl From<Utf8Error> for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Error {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
write!(f, "{self:#?}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Trait for interacting with the music library.
|
/// Trait for interacting with the music library.
|
||||||
pub trait Library {
|
pub trait Library {
|
||||||
/// List lirbary items that match the a specific query.
|
/// List lirbary items that match the a specific query.
|
||||||
|
19
src/main.rs
19
src/main.rs
@ -1,4 +1,4 @@
|
|||||||
use std::{path::PathBuf, process::exit};
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
@ -40,18 +40,13 @@ fn main() {
|
|||||||
SystemExecutor::default().config(opt.beets_config_file_path.as_deref()),
|
SystemExecutor::default().config(opt.beets_config_file_path.as_deref()),
|
||||||
));
|
));
|
||||||
|
|
||||||
let collection = match beets.list(&Query::new()) {
|
let collection = beets
|
||||||
Ok(collection) => collection,
|
.list(&Query::new())
|
||||||
Err(e) => {
|
.expect("failed to query the library");
|
||||||
println!("{e}");
|
|
||||||
exit(1)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut database = DatabaseJson::new(Box::new(DatabaseJsonFile::new(&opt.database_file_path)));
|
let mut database = DatabaseJson::new(Box::new(DatabaseJsonFile::new(&opt.database_file_path)));
|
||||||
|
|
||||||
if let Err(e) = database.write(&collection) {
|
database
|
||||||
println!("{e}");
|
.write(&collection)
|
||||||
exit(1)
|
.expect("failed to write to the database");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user