diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-06-20 07:20:46 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-06-20 07:32:54 +0800 |
| commit | 9b896d697eb582dedd2533f6d2054f062c8381a0 (patch) | |
| tree | b7e8db33af8e6837f3d389d4302b821d401ec0d8 /src/args.rs | |
| parent | 69354929928d1d071698262c259cdffbf9aec468 (diff) | |
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.
Diffstat (limited to 'src/args.rs')
| -rw-r--r-- | src/args.rs | 6 |
1 files changed, 6 insertions, 0 deletions
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, |
