46 lines
1.1 KiB
Rust
46 lines
1.1 KiB
Rust
use clap::{Parser, Subcommand};
|
|
use photojawn::generate::generate;
|
|
use photojawn::skel::make_skeleton;
|
|
use std::path::Path;
|
|
|
|
fn main() -> anyhow::Result<()> {
|
|
env_logger::init();
|
|
let cli = Cli::parse();
|
|
let album_path = Path::new(&cli.album_path).canonicalize()?;
|
|
|
|
match cli.subcommand {
|
|
Commands::Init {} => {
|
|
make_skeleton(&album_path)?;
|
|
println!("Album created in {}", album_path.display());
|
|
}
|
|
Commands::Generate { full } => {
|
|
let path = generate(&album_path.to_path_buf(), full)?;
|
|
println!("Album site generated in {}", path.display());
|
|
}
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[derive(Parser)]
|
|
#[command(version, about, long_about = None)]
|
|
struct Cli {
|
|
/// Path to the album
|
|
#[arg(long, default_value = ".")]
|
|
album_path: String,
|
|
|
|
#[command(subcommand)]
|
|
subcommand: Commands,
|
|
}
|
|
|
|
#[derive(Subcommand)]
|
|
enum Commands {
|
|
/// Initialize a new Photojawn album directory
|
|
Init {},
|
|
/// Generates a photo album
|
|
Generate {
|
|
/// Regenerate everything, including images that have already been generated
|
|
#[arg(long)]
|
|
full: bool,
|
|
},
|
|
}
|