From 9b896d697eb582dedd2533f6d2054f062c8381a0 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sat, 20 Jun 2026 07:20:46 +0800 Subject: feat: add custom help message and fix clap help conflict Disable clap's built-in help flag and reroute `-h`/`--help` to print an embedded help text from `help.txt`. Use `try_parse` to avoid clap's default exit on parse failure, allowing custom error output. --- src/args.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/args.rs') diff --git a/src/args.rs b/src/args.rs index 52dddfc..c27ff78 100644 --- a/src/args.rs +++ b/src/args.rs @@ -14,9 +14,15 @@ macro_rules! debug_log { }; } +/// The full help text embedded at compile time. +pub static HELP_TEXT: &str = include_str!("../help.txt"); + #[derive(clap::Parser)] #[command(name = "dmvop", disable_help_flag = true, disable_version_flag = true)] pub struct DMVOPArguments { + // Show help + #[arg(long = "help", short = 'h')] + pub help: bool, // Verbose output (show debug messages) #[arg(long = "verbose", short = 'V')] pub verbose: bool, -- cgit