forked from proxmox-mirrors/proxmox
proxmox-api: fix text_wrap() - use join instead of concat (separate by newlines)
This commit is contained in:
parent
6afad53466
commit
354cfabd37
@ -48,15 +48,26 @@ pub fn wrap_text(
|
|||||||
.filter(|p| !p.is_empty())
|
.filter(|p| !p.is_empty())
|
||||||
.fold(String::new(), |mut acc, p| {
|
.fold(String::new(), |mut acc, p| {
|
||||||
if acc.is_empty() {
|
if acc.is_empty() {
|
||||||
acc.push_str(&wrapper1.wrap(p).concat());
|
acc.push_str(&wrapper1.wrap(p).join("\n"));
|
||||||
} else {
|
} else {
|
||||||
acc.push_str(&wrapper2.wrap(p).concat());
|
acc.push_str(&wrapper2.wrap(p).join("\n"));
|
||||||
}
|
}
|
||||||
acc.push_str("\n\n");
|
acc.push_str("\n\n");
|
||||||
acc
|
acc
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_wrap_text() {
|
||||||
|
let text = "Command. This may be a list in order to spefify nested sub-commands.";
|
||||||
|
let expect = " Command. This may be a list in order to spefify nested sub-\n commands.\n\n";
|
||||||
|
|
||||||
|
let indent = " ";
|
||||||
|
let wrapped = wrap_text(indent, indent, text, 80);
|
||||||
|
|
||||||
|
assert_eq!(wrapped, expect);
|
||||||
|
}
|
||||||
|
|
||||||
/// TODO: Document output format.
|
/// TODO: Document output format.
|
||||||
pub fn get_schema_type_text(schema: &Schema, _style: ParameterDisplayStyle) -> String {
|
pub fn get_schema_type_text(schema: &Schema, _style: ParameterDisplayStyle) -> String {
|
||||||
match schema {
|
match schema {
|
||||||
|
Loading…
Reference in New Issue
Block a user