moved gen-wallpapers to its own crate, outputing json to stdout
This commit is contained in:
parent
0904feb383
commit
f3a6e1c8a5
6 changed files with 868 additions and 674 deletions
31
crates/gen-wallpapers/examples/cli.rs
Normal file
31
crates/gen-wallpapers/examples/cli.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
use clap::Parser;
|
||||
use gen_wallpapers::MetadataList;
|
||||
use std::fs::read_dir;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Parser)]
|
||||
struct Cli {
|
||||
folder: PathBuf,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let cli = Cli::parse();
|
||||
let dir = match read_dir(cli.folder) {
|
||||
Ok(dir) => dir,
|
||||
Err(e) => {
|
||||
eprintln!("failed to read folder: {e}");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let metadata = MetadataList::process_folder(dir, true);
|
||||
|
||||
let json = match metadata.to_json() {
|
||||
Ok(json) => json,
|
||||
Err(e) => {
|
||||
eprintln!("failed to serialize json: {e}");
|
||||
return;
|
||||
}
|
||||
};
|
||||
println!("{json}");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue