From fe65ea55078a5fa7d68eccb6d107a1477a26f9d6 Mon Sep 17 00:00:00 2001 From: yuma14 Date: Sun, 15 Oct 2023 13:35:44 +0900 Subject: [PATCH] feat(help): add help message for subcommands --- Cargo.toml | 2 +- src/cli.rs | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4c649e0..e3759e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ keywords = ["ssg", "templating", "web", "markdown"] [dependencies] anyhow = "1.0.75" -clap = { version = "4.4.6", features = ["derive"] } +clap = { version = "4.4.6", features = ["derive", "help"] } handlebars = "4.4.0" matter = "0.1.0-alpha4" once_cell = "1.18.0" diff --git a/src/cli.rs b/src/cli.rs index df2436f..20ee0ae 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -3,7 +3,14 @@ use std::path::PathBuf; use clap::{Parser, Subcommand}; #[derive(Parser, Debug)] -#[command(author, version, about, long_about = None)] +#[command(author, version, about, long_about = None, help_template = "\ +{before-help}{name} {version} +{tab}by {author} +{about-with-newline} +{usage-heading} {usage} + +{all-args}{after-help} +")] pub struct Cli { #[command(subcommand)] pub command: Commands, @@ -11,10 +18,12 @@ pub struct Cli { #[derive(Subcommand, Debug)] pub enum Commands { + /// Initializes a Tempura project Init { #[arg(default_value = ".")] directory: PathBuf, }, + /// Builds website Build { #[arg(default_value = ".")] directory: PathBuf,