mirror of
https://codeberg.org/icewind/haze.git
synced 2026-06-03 17:14:08 +02:00
make it easier to change php configuration
This commit is contained in:
parent
16cb573935
commit
4bb6a21d7c
6 changed files with 71 additions and 0 deletions
28
src/help.rs
28
src/help.rs
|
|
@ -231,4 +231,32 @@ fn subcommand_help(command: &dyn SubCommand) {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(details) = command.get_str("Details") {
|
||||
println!("{}", format_details(details));
|
||||
}
|
||||
}
|
||||
|
||||
fn format_details(details: &str) -> String {
|
||||
use std::fmt::Write;
|
||||
let mut result = String::with_capacity(details.len());
|
||||
for (i, part) in details.split("</").enumerate() {
|
||||
let part = if i > 0 {
|
||||
// strip the remaining close tag from the previous part
|
||||
part.split_once('>').map(|(_, part)| part).unwrap_or(part)
|
||||
} else {
|
||||
part
|
||||
};
|
||||
let (head, tail) = part.split_once('<').unwrap_or((part, ""));
|
||||
result.push_str(head);
|
||||
if let Some((tag, content)) = tail.split_once('>') {
|
||||
match tag {
|
||||
"literal" => write!(&mut result, "{}", content.blue()).unwrap(),
|
||||
"arg" => write!(&mut result, "{}", content.green()).unwrap(),
|
||||
"yellow" => write!(&mut result, "{}", content.bright_yellow()).unwrap(),
|
||||
_ => write!(&mut result, "{content}").unwrap(),
|
||||
}
|
||||
}
|
||||
}
|
||||
result
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue