use crate::display::theme::Theme;
use console::style;
pub fn format_help_section(title: &str, content: &str, indent: bool) -> String {
let mut output = String::new();
if Theme::should_disable_colors() {
output.push_str(&format!("{title}\n"));
} else {
output.push_str(&format!("{}\n", style(title).cyan().bold()));
}
for line in content.lines() {
if line.trim().is_empty() {
output.push('\n');
} else if indent && !line.starts_with(" ") {
output.push_str(&format!(" {line}\n"));
} else {
output.push_str(&format!("{line}\n"));
}
}
output
}
pub fn create_help_text() -> String {
let mut help = String::new();
let quick_start = r#"$ codanna init # Initialize in current directory
$ codanna index src # Index your source code
$ codanna serve --http --watch # HTTP server with OAuth
$ codanna serve --https --watch # HTTPS server with TLS"#;
help.push_str(&format_help_section("QUICK START", quick_start, true));
help.push('\n');
let learn_more = r#"GitHub: https://github.com/bartolli/codanna"#;
help.push_str(&format_help_section("LEARN MORE", learn_more, true));
help
}
pub fn format_command_description(name: &str, description: &str) -> String {
if Theme::should_disable_colors() {
format!("{name:16} {description}")
} else {
format!("{:16} {}", style(name).green(), description)
}
}