From: Shannon Sterz <s.sterz@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager 2/2] cli/admin: add a versions command to show current package versions
Date: Fri, 5 Sep 2025 11:59:06 +0200 [thread overview]
Message-ID: <20250905095906.204396-4-s.sterz@proxmox.com> (raw)
In-Reply-To: <20250905095906.204396-1-s.sterz@proxmox.com>
similar to other proxmox products this shows the currently running
version as well as offering a verbose option that can show versions
for other relevant packages as well.
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
cli/admin/src/main.rs | 53 +++++++++++++++++++++++++++++++++++++++++--
1 file changed, 51 insertions(+), 2 deletions(-)
diff --git a/cli/admin/src/main.rs b/cli/admin/src/main.rs
index 91b93f3..aa0897a 100644
--- a/cli/admin/src/main.rs
+++ b/cli/admin/src/main.rs
@@ -1,4 +1,11 @@
-use proxmox_router::cli::{run_cli_command, CliCommandMap, CliEnvironment};
+use serde_json::{json, Value};
+
+use proxmox_router::cli::{
+ default_table_format_options, format_and_print_result_full, get_output_format, run_cli_command,
+ CliCommand, CliCommandMap, CliEnvironment, ColumnConfig, OUTPUT_FORMAT,
+};
+
+use proxmox_schema::api;
mod remotes;
@@ -12,7 +19,9 @@ fn main() {
server::context::init().expect("could not set up server context");
- let cmd_def = CliCommandMap::new().insert("remote", remotes::cli());
+ let cmd_def = CliCommandMap::new()
+ .insert("remote", remotes::cli())
+ .insert("versions", CliCommand::new(&API_METHOD_GET_VERSIONS));
let rpcenv = CliEnvironment::new();
run_cli_command(
@@ -21,3 +30,43 @@ fn main() {
Some(|future| proxmox_async::runtime::main(future)),
);
}
+
+#[api(
+ input: {
+ properties: {
+ verbose: {
+ type: Boolean,
+ optional: true,
+ default: false,
+ description: "Output verbose package information. It is ignored if output-format is specified.",
+ },
+ "output-format": {
+ schema: OUTPUT_FORMAT,
+ optional: true,
+ }
+ }
+ }
+)]
+/// List package versions for important Proxmox Datacenter Manager packages.
+async fn get_versions(verbose: bool, param: Value) -> Result<Value, anyhow::Error> {
+ let output_format = get_output_format(¶m);
+
+ let packages = server::api::nodes::apt::get_versions()?;
+ let mut packages = json!(if verbose {
+ &packages[..]
+ } else {
+ &packages[1..2]
+ });
+
+ let options = default_table_format_options()
+ .disable_sort()
+ .noborder(true) // just not helpful for version info which gets copy pasted often
+ .column(ColumnConfig::new("Package"))
+ .column(ColumnConfig::new("Version"))
+ .column(ColumnConfig::new("ExtraInfo").header("Extra Info"));
+ let return_type = &server::api::nodes::apt::API_METHOD_GET_VERSIONS.returns;
+
+ format_and_print_result_full(&mut packages, return_type, &output_format, &options);
+
+ Ok(Value::Null)
+}
--
2.47.2
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
next prev parent reply other threads:[~2025-09-05 9:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-05 9:59 [pdm-devel] [PATCH datacenter-manager/proxmox 0/3] version command and upgrade checks for pdm Shannon Sterz
2025-09-05 9:59 ` [pdm-devel] [PATCH proxmox 1/1] upgrade-checks: add upgrade checker crate Shannon Sterz
2025-09-05 14:08 ` Michael Köppl
2025-09-05 9:59 ` [pdm-devel] [PATCH datacenter-manager 1/2] server: add pdmAtoB upgrade checker script Shannon Sterz
2025-09-05 9:59 ` Shannon Sterz [this message]
2025-09-05 15:18 ` [pdm-devel] [PATCH datacenter-manager/proxmox 0/3] version command and upgrade checks for pdm Michael Köppl
2025-09-05 10:04 Shannon Sterz
2025-09-05 10:04 ` [pdm-devel] [PATCH datacenter-manager 2/2] cli/admin: add a versions command to show current package versions Shannon Sterz
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=20250905095906.204396-4-s.sterz@proxmox.com \
--to=s.sterz@proxmox.com \
--cc=pdm-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.