1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*[toml]
[dependencies]
thag_common = { version = "0.2, thag-auto" }
*/
/// Demo tool to showcase the lightweight help system.
///
/// This tool demonstrates how to use the built-in help system for thag tools.
/// It shows how help information is extracted from comments and displayed consistently.
//# Purpose: Demonstrate the lightweight help system for thag tools
//# Categories: demo, tools
//# Usage: thag_demo_help [--help|-h]
use std::env;
use thag_common::{auto_help, help_system::check_help_and_exit};
fn main() {
// Initialize help system from source comments automatically
let help = auto_help!();
// Check if help was requested and exit if so
check_help_and_exit(&help);
// Main program logic
let args: Vec<String> = env::args().collect();
if args.len() > 1 {
println!("You provided {} argument(s):", args.len() - 1);
for (i, arg) in args.iter().skip(1).enumerate() {
println!(" {}: {}", i + 1, arg);
}
} else {
println!("This is a demo tool showcasing the thag help system!");
println!("Try running with --help to see the help information.");
println!("You can also pass some arguments to see them echoed back.");
}
println!("\nThis help information was automatically extracted from source comments.");
}