use colored::*;
pub enum HelpOptions {
DontPrintCommandSection,
PrintCommandSection,
PrintCommandSectionWithExternalCommandHint,
}
pub fn help_template(command_help: HelpOptions) -> String {
let mut template = format!(
"{{about}}\n\n\
{} {{usage}}\n\n\
{{positionals}}\n\n\
{}\n\
{{options}}",
"Usage:".bright_green().bold(),
"Options:".bright_green().bold(),
);
match command_help {
HelpOptions::PrintCommandSection
| HelpOptions::PrintCommandSectionWithExternalCommandHint => {
template.push_str(&format!(
"\n\n\
{}\n\
{{subcommands}}",
"Commands:".bright_green().bold(),
));
if let HelpOptions::PrintCommandSectionWithExternalCommandHint = command_help {
template.push_str(&format!(
"\n\
{}{}",
" ... ".bold(),
"See external installed commands with --list"
));
}
}
HelpOptions::DontPrintCommandSection => {}
}
template
}