2023-10-18 19:47:05 -04:00
|
|
|
use clap::Args;
|
|
|
|
use clap::Parser;
|
|
|
|
use clap::Subcommand;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
#[derive(Parser, Debug)]
|
2023-12-21 19:28:31 -05:00
|
|
|
#[command(name = "Natter")]
|
2023-10-18 19:47:05 -04:00
|
|
|
#[command(version = env!("CARGO_PKG_VERSION"))]
|
|
|
|
#[command(about = "Generate a static site.", long_about = None)]
|
|
|
|
#[command(propagate_version = true)]
|
|
|
|
pub(crate) struct Cli {
|
|
|
|
#[command(subcommand)]
|
|
|
|
pub(crate) command: Commands,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subcommand, Debug)]
|
|
|
|
pub(crate) enum Commands {
|
|
|
|
/// Initialize an empty website folder.
|
|
|
|
Init(InitArgs),
|
|
|
|
|
|
|
|
/// Build the static site.
|
|
|
|
Build(BuildArgs),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Args, Debug)]
|
|
|
|
pub(crate) struct InitArgs {
|
2023-12-21 19:28:31 -05:00
|
|
|
/// Path where you want the initial natter structure to be located.
|
2023-10-18 19:47:05 -04:00
|
|
|
#[arg(short, long)]
|
|
|
|
pub(crate) path: PathBuf,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Args, Debug)]
|
|
|
|
pub(crate) struct BuildArgs {
|
2023-12-21 19:28:31 -05:00
|
|
|
/// Path to the natter config file.
|
2023-10-18 19:47:05 -04:00
|
|
|
#[arg(short, long)]
|
|
|
|
pub(crate) config: PathBuf,
|
|
|
|
}
|
|
|
|
|
2023-10-18 19:49:03 -04:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn verify_cli() {
|
|
|
|
use clap::CommandFactory;
|
|
|
|
Cli::command().debug_assert()
|
|
|
|
}
|
|
|
|
}
|