use clap::Args; use clap::Parser; use clap::Subcommand; use std::path::PathBuf; use std::process::ExitCode; fn main() -> Result> { let rt = tokio::runtime::Runtime::new()?; rt.block_on(async { let main_body_result = main_body().await; main_body_result }) } async fn main_body() -> Result> { let args = Cli::parse(); match args.command { Commands::Init(_args) => {} Commands::Build(_args) => {} Commands::AddPost(_args) => {} }; Ok(ExitCode::SUCCESS) } #[derive(Parser, Debug)] #[command(name = "Writer")] #[command(version = env!("CARGO_PKG_VERSION"))] #[command(about = "Generate a static site.", long_about = None)] #[command(propagate_version = true)] struct Cli { #[command(subcommand)] command: Commands, } #[derive(Subcommand, Debug)] enum Commands { /// Initialize an empty website folder. Init(InitArgs), /// Build the static site. Build(BuildArgs), /// Add a blog post to the site. AddPost(BuildArgs), } #[derive(Args, Debug)] struct InitArgs { /// Path where you want the initial writer structure to be located. #[arg(short, long)] path: PathBuf, } #[derive(Args, Debug)] struct BuildArgs { /// Path to the writer config file. #[arg(short, long)] config: PathBuf, } #[derive(Args, Debug)] struct AddPostArgs { /// Path to the writer config file. #[arg(short, long)] config: PathBuf, }