From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 9B21D1FF0E9 for ; Thu, 16 Jul 2026 12:31:23 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 5EB572143D; Thu, 16 Jul 2026 12:31:23 +0200 (CEST) From: Christoph Heiss To: pbs-devel@lists.proxmox.com Subject: [PATCH proxmox-backup 1/2] manager: user: make 'user generate-token' accept --output-format Date: Thu, 16 Jul 2026 12:29:56 +0200 Message-ID: <20260716103108.724902-2-c.heiss@proxmox.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260716103108.724902-1-c.heiss@proxmox.com> References: <20260716103108.724902-1-c.heiss@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1784197859806 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.000 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_LOW -0.7 Sender listed at https://www.dnswl.org/, low trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: MM5YSTYBZGEFES6ROEKHVY7FTGBLMTVV X-Message-ID-Hash: MM5YSTYBZGEFES6ROEKHVY7FTGBLMTVV X-MailFrom: c.heiss@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Needs a small wrapper (like most other commands) to parse the option and print the result formatted appropriately. Before, when invoking 'proxmox-backup-manager user generate-token [..]', the output would be a mix of human-readable and machine-readable: Result: { "tokenid": "root@pam!my-token", "value": ".." } Signed-off-by: Christoph Heiss --- Ran across this while working on something else, definitely worth fixing. src/bin/proxmox_backup_manager/user.rs | 39 ++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/bin/proxmox_backup_manager/user.rs b/src/bin/proxmox_backup_manager/user.rs index 87c1f4394..a429823de 100644 --- a/src/bin/proxmox_backup_manager/user.rs +++ b/src/bin/proxmox_backup_manager/user.rs @@ -6,7 +6,7 @@ use std::collections::HashMap; use proxmox_router::{ApiHandler, RpcEnvironment, cli::*}; use proxmox_schema::api; -use pbs_api_types::{ACL_PATH_SCHEMA, Authid, Userid}; +use pbs_api_types::{ACL_PATH_SCHEMA, Authid, Tokenname, Userid}; use proxmox_backup::api2; @@ -101,6 +101,41 @@ fn list_tokens(param: Value, rpcenv: &mut dyn RpcEnvironment) -> Result Result { + let output_format = get_output_format(¶m); + + let info = &api2::access::user::API_METHOD_GENERATE_TOKEN; + let mut data = match info.handler { + ApiHandler::Sync(handler) => (handler)(param, info, rpcenv)?, + _ => unreachable!(), + }; + + let options = default_table_format_options() + .column(ColumnConfig::new("tokenid")) + .column(ColumnConfig::new("value")); + + format_and_print_result_full(&mut data, &info.returns, &output_format, &options); + + Ok(Value::Null) +} + #[api( input: { properties: { @@ -219,7 +254,7 @@ pub fn user_commands() -> CommandLineInterface { ) .insert( "generate-token", - CliCommand::new(&api2::access::user::API_METHOD_GENERATE_TOKEN) + CliCommand::new(&API_METHOD_GENERATE_TOKEN) .arg_param(&["userid", "token-name"]) .completion_cb("userid", pbs_config::user::complete_userid), ) -- 2.54.0