Simple tool for automatic file management
1use color_eyre::eyre::Result; 2use tokio_stream::iter; 3use futures::StreamExt; 4 5mod filters; 6mod job; 7mod pattern; 8 9const DATA: &str = r#" 10[ 11 { 12 "filters": [ 13 {"type": "name", "Wildcard": "*.dmg"} 14 ], 15 "location": "~/Downloads", 16 "actions": [ 17 {"message": "move to ~/Documents/Gitara/"} 18 ] 19 } 20]"#; 21 22#[tokio::main] 23async fn main() -> Result<()> { 24 let jobs: Vec<job::Job> = serde_json::from_str(DATA).unwrap(); 25 26 iter(&jobs) 27 .then(|job| job.run()) 28 .map(|result| result.unwrap()) 29 .flatten() 30 .for_each_concurrent(None, |(action, path)| action.execute(path)) 31 .await; 32 33 Ok(()) 34}