2023-10-18 19:26:04 -04:00
|
|
|
use std::process::ExitCode;
|
|
|
|
|
2023-10-18 19:47:05 -04:00
|
|
|
use clap::Parser;
|
|
|
|
|
|
|
|
use self::cli::parameters::Cli;
|
|
|
|
use self::cli::parameters::Commands;
|
2023-10-20 19:13:22 -04:00
|
|
|
use self::command::build::build_site;
|
2023-10-18 20:21:28 -04:00
|
|
|
use self::command::init::init_writer_folder;
|
2023-10-22 13:44:03 -04:00
|
|
|
use self::error::CustomError;
|
2023-10-22 12:04:09 -04:00
|
|
|
mod blog_post;
|
2023-10-18 19:47:05 -04:00
|
|
|
mod cli;
|
2023-10-18 19:54:18 -04:00
|
|
|
mod command;
|
2023-10-18 19:59:45 -04:00
|
|
|
mod config;
|
2023-10-22 13:44:03 -04:00
|
|
|
mod error;
|
2023-10-22 16:26:43 -04:00
|
|
|
mod render;
|
2023-10-18 19:47:05 -04:00
|
|
|
|
2023-10-22 13:44:03 -04:00
|
|
|
fn main() -> Result<ExitCode, CustomError> {
|
2023-10-18 19:26:04 -04:00
|
|
|
let rt = tokio::runtime::Runtime::new()?;
|
|
|
|
rt.block_on(async {
|
|
|
|
let main_body_result = main_body().await;
|
|
|
|
main_body_result
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-10-22 13:44:03 -04:00
|
|
|
async fn main_body() -> Result<ExitCode, CustomError> {
|
2023-10-18 19:26:04 -04:00
|
|
|
let args = Cli::parse();
|
|
|
|
match args.command {
|
2023-10-18 20:21:28 -04:00
|
|
|
Commands::Init(args) => {
|
2023-10-20 19:13:22 -04:00
|
|
|
init_writer_folder(args).await?;
|
|
|
|
}
|
|
|
|
Commands::Build(args) => {
|
|
|
|
build_site(args).await?;
|
2023-10-18 20:21:28 -04:00
|
|
|
}
|
2023-10-18 19:26:04 -04:00
|
|
|
};
|
|
|
|
Ok(ExitCode::SUCCESS)
|
|
|
|
}
|