mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-06-15 14:24:55 +00:00
system report: switch to markdown-like output
allows one to render this via any of the thousands markdown viewers to get a better formatting. We can switch our web ui widget to (optionally) render this as html when a user is viewing it from the UI too. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
11c4632bcf
commit
20875de2ec
@ -72,7 +72,8 @@ pub fn generate_report() -> String {
|
|||||||
Ok(None) => String::from("# file does not exist"),
|
Ok(None) => String::from("# file does not exist"),
|
||||||
Err(err) => err.to_string(),
|
Err(err) => err.to_string(),
|
||||||
};
|
};
|
||||||
format!("$ cat '{}'\n{}", file_name, content)
|
let content = content.trim_end();
|
||||||
|
format!("`$ cat '{file_name}'`\n```\n{content}\n```")
|
||||||
})
|
})
|
||||||
.collect::<Vec<String>>()
|
.collect::<Vec<String>>()
|
||||||
.join("\n\n");
|
.join("\n\n");
|
||||||
@ -88,19 +89,22 @@ pub fn generate_report() -> String {
|
|||||||
Ok(output) => String::from_utf8_lossy(&output.stdout).to_string(),
|
Ok(output) => String::from_utf8_lossy(&output.stdout).to_string(),
|
||||||
Err(err) => err.to_string(),
|
Err(err) => err.to_string(),
|
||||||
};
|
};
|
||||||
format!("$ `{} {}`\n{}", command, args.join(" "), output)
|
let output = output.trim_end();
|
||||||
|
format!("$ `{command} {}`\n```\n{output}\n```", args.join(" "))
|
||||||
})
|
})
|
||||||
.collect::<Vec<String>>()
|
.collect::<Vec<String>>()
|
||||||
.join("\n\n");
|
.join("\n\n");
|
||||||
|
|
||||||
let function_outputs = function_calls()
|
let function_outputs = function_calls()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(desc, function)| format!("$ {}\n{}", desc, function()))
|
.map(|(desc, function)| {
|
||||||
|
let output = function();
|
||||||
|
format!("#### {desc}\n```\n{}\n```", output.trim_end())
|
||||||
|
})
|
||||||
.collect::<Vec<String>>()
|
.collect::<Vec<String>>()
|
||||||
.join("\n\n");
|
.join("\n\n");
|
||||||
|
|
||||||
format!(
|
format!(
|
||||||
"= FILES =\n\n{}\n= COMMANDS =\n\n{}\n= FUNCTIONS =\n\n{}\n",
|
"## FILES\n\n{file_contents}\n## COMMANDS\n\n{command_outputs}\n## FUNCTIONS\n\n{function_outputs}\n"
|
||||||
file_contents, command_outputs, function_outputs
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user