Create the main binary #15

Merged
wojtek merged 4 commits from 7---create-the-main-binary into main 2023-04-10 00:13:18 +02:00
2 changed files with 8 additions and 19 deletions
Showing only changes of commit 5a6f7e51e7 - Show all commits

View File

@ -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.

View File

@ -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");
}
} }