mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-28 10:47:13 +00:00
proxmox/api/cli: add extract_output_format
just getting it is not enough, sometimes we want it to remove from params (if possble) too Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
4dda9b5865
commit
77b85f7dc1
@ -25,6 +25,18 @@ pub fn get_output_format(param: &Value) -> String {
|
||||
output_format.unwrap_or_else(|| String::from("text"))
|
||||
}
|
||||
|
||||
/// Helper to get output format from parameters or environment
|
||||
/// and removing from parameters
|
||||
pub fn extract_output_format(param: &mut Value) -> String {
|
||||
let output_format = get_output_format(param);
|
||||
|
||||
if let Some(param) = param.as_object_mut() {
|
||||
param.remove("output-format");
|
||||
}
|
||||
|
||||
output_format
|
||||
}
|
||||
|
||||
/// Helper to get TableFormatOptions with default from environment
|
||||
pub fn default_table_format_options() -> TableFormatOptions {
|
||||
let no_border = std::env::var(ENV_VAR_PROXMOX_OUTPUT_NO_BORDER)
|
||||
|
Loading…
Reference in New Issue
Block a user