pmm+pdm: -v/--version on both; pdm update (install latest pmm tools, auto os/arch); hint path root/bin

这个提交包含在:
JGZYES
2026-08-30 19:20:20 +08:00
父节点 1aa9c3a416
当前提交 3d8e319f8f
修改 2 个文件,包含 17 行新增3 行删除
+3 -3
查看文件
@@ -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;
}
+14
查看文件
@@ -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 <dir> [output.pdm]\n"); return 1; }
return pdm_pack(argv[2], argc >= 4 ? argv[3] : NULL) == 0 ? 0 : 1;