1use colored::*;
14
15pub enum HelpOptions {
16 DontPrintCommandSection,
17 PrintCommandSection,
18 PrintCommandSectionWithExternalCommandHint,
19}
20
21pub fn help_template(command_help: HelpOptions) -> String {
22 let mut template = format!(
23 "{{about}}\n\n\
24 {} {{usage}}\n\n\
25 {{positionals}}\n\n\
26 {}\n\
27 {{options}}",
28 "Usage:".bright_green().bold(),
29 "Options:".bright_green().bold(),
30 );
31
32 match command_help {
33 HelpOptions::PrintCommandSection
34 | HelpOptions::PrintCommandSectionWithExternalCommandHint => {
35 template.push_str(&format!(
36 "\n\n\
37 {}\n\
38 {{subcommands}}",
39 "Commands:".bright_green().bold(),
40 ));
41
42 if let HelpOptions::PrintCommandSectionWithExternalCommandHint = command_help {
43 template.push_str(&format!(
44 "\n\
45 {}{}",
46 " ... ".bold(),
47 "See external installed commands with --list"
48 ));
49 }
50 }
51 HelpOptions::DontPrintCommandSection => {}
52 }
53
54 template
55}