From 3d8e319f8fca6e7a23a4401db53b69e893d08fd0 Mon Sep 17 00:00:00 2001 From: JGZYES Date: Sun, 30 Aug 2026 19:20:20 +0800 Subject: [PATCH] pmm+pdm: -v/--version on both; pdm update (install latest pmm tools, auto os/arch); hint path root/bin --- src/main.c | 6 +++--- src/pdm_main.c | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index c5cef0d..1d11433 100644 --- a/src/main.c +++ b/src/main.c @@ -345,8 +345,8 @@ int main(int argc, char **argv) { if (strcmp(argv[1], "help") == 0 || strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0) { print_help(); return 0; } - if (strcmp(argv[1], "version") == 0 || strcmp(argv[1], "--version") == 0) { - printf("pmm %s (%s)\n", PMM_VERSION, pmm_os_name(pmm_detect_os())); + if (strcmp(argv[1], "version") == 0 || strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-v") == 0) { + printf("pmm %s (%s) [%s]\n", PMM_VERSION, pmm_os_name(pmm_detect_os()), pmm_detect_arch()); return 0; } if (strcmp(argv[1], "list") == 0) return cmd_list(); @@ -367,7 +367,7 @@ int main(int argc, char **argv) { free(cfg.registry_url); free(cfg.mirror_name); free(mirror.name); free(mirror.api_base); if (rc == 0) - printf("pmm: updated. New tools are under %s/bin (pmm/pdm). Re-run from there, or add it to PATH.\n", + printf("pmm: updated. New tools are under %s/root/bin (pmm/pdm). Re-run from there, or add it to PATH.\n", pmm_config_dir((char[1024]){0}, 1024)); return rc == 0 ? 0 : 1; } diff --git a/src/pdm_main.c b/src/pdm_main.c index e78525c..ef8e6a8 100644 --- a/src/pdm_main.c +++ b/src/pdm_main.c @@ -56,6 +56,20 @@ int main(int argc, char **argv) { pmm_set_self_path(argv[0]); argc = consume_drive_flag(argc, argv); if (argc < 2) { usage(); return 0; } + /* version: pdm -v / --version */ + if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-v") == 0) { + printf("pdm %s (%s) [%s]\n", PMM_VERSION, pmm_os_name(pmm_detect_os()), pmm_detect_arch()); + return 0; + } + /* self-update: install the latest pmm tool package (contains pmm + pdm) */ + if (strcmp(argv[1], "update") == 0 || strcmp(argv[1], "self-update") == 0) { + printf("pdm: updating pmm+pdm for %s/%s\n", pmm_os_name(pmm_detect_os()), pmm_detect_arch()); + int rc = install_from_registry("pmm", NULL, NULL); + if (rc == 0) + printf("pdm: updated. New tools are under %s/root/bin\n", + pmm_config_dir((char[1024]){0}, 1024)); + return rc == 0 ? 0 : 1; + } if (strcmp(argv[1], "pack") == 0) { if (argc < 3) { fprintf(stderr, "pdm: usage: pdm pack [output.pdm]\n"); return 1; } return pdm_pack(argv[2], argc >= 4 ? argv[3] : NULL) == 0 ? 0 : 1;