public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox 1/1] proxmox/api/cli: add extract_output_format
Date: Fri, 30 Apr 2021 14:51:55 +0200	[thread overview]
Message-ID: <20210430125156.20072-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20210430125156.20072-1-d.csapak@proxmox.com>

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>
---
 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)
-- 
2.20.1





  reply	other threads:[~2021-04-30 12:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-30 12:51 [pbs-devel] [PATCH proxmox/proxmox-backup] fix some proxmox-tape calls Dominik Csapak
2021-04-30 12:51 ` Dominik Csapak [this message]
2021-05-03  7:03   ` [pbs-devel] applied: [PATCH proxmox 1/1] proxmox/api/cli: add extract_output_format Dietmar Maurer
2021-04-30 12:51 ` [pbs-devel] [PATCH proxmox-backup 1/1] bin: use extract_output_format where necessary Dominik Csapak
2021-05-03  7:04   ` [pbs-devel] applied: " Dietmar Maurer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210430125156.20072-2-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal