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