use std::path::PathBuf; use structopt::StructOpt; use musichoard::{ database::{ json::{DatabaseJson, DatabaseJsonFile}, DatabaseWrite, }, library::{ beets::{Beets, SystemExecutor}, Library, Query, }, }; #[derive(StructOpt)] struct Opt { #[structopt( short = "b", long = "beets-config", name = "beets config file path", parse(from_os_str) )] beets_config_file_path: Option, #[structopt( short = "d", long = "database", name = "database file path", default_value = "database.json", parse(from_os_str) )] database_file_path: PathBuf, } fn main() { let opt = Opt::from_args(); let mut beets = Beets::new(Box::new( unsafe { SystemExecutor::default().config(opt.beets_config_file_path.as_deref()) }, )); let collection = beets .list(&Query::new()) .expect("failed to query the library"); let mut database = DatabaseJson::new(Box::new(DatabaseJsonFile::new(&opt.database_file_path))); database .write(&collection) .expect("failed to write to the database"); }