[pbs-devel] applied: [PATCH proxmox 1/1] proxmox/api/cli: add extract_output_format
Dietmar Maurer
dietmar at proxmox.com
Mon May 3 09:03:55 CEST 2021
applied
On 4/30/21 2:51 PM, Dominik Csapak wrote:
> just getting it is not enough, sometimes we want it to remove from
> params (if possble) too
>
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
> proxmox/src/api/cli/text_table.rs | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/proxmox/src/api/cli/text_table.rs b/proxmox/src/api/cli/text_table.rs
> index 5ff2db0..84d9f34 100644
> --- a/proxmox/src/api/cli/text_table.rs
> +++ b/proxmox/src/api/cli/text_table.rs
> @@ -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)
More information about the pbs-devel
mailing list