natter/src/main.rs

67 lines
1.5 KiB
Rust
Raw Normal View History

2023-10-18 23:26:04 +00:00
use clap::Args;
use clap::Parser;
use clap::Subcommand;
use std::path::PathBuf;
use std::process::ExitCode;
fn main() -> Result<ExitCode, Box<dyn std::error::Error>> {
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<ExitCode, Box<dyn std::error::Error>> {
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,
2023-10-18 23:03:45 +00:00
}