Implement r2pm -cp like it was in r2pm.sh ##r2pm

This commit is contained in:
pancake 2022-10-29 19:03:41 +02:00 committed by pancake
parent e317a0666e
commit 6ec1d8667d
2 changed files with 20 additions and 2 deletions

View File

@ -62,6 +62,7 @@ typedef struct r_r2pm_t {
bool clean;
bool force;
bool global;
bool plugdir; // requires -c/clean
bool list;
bool add;
bool init;
@ -766,7 +767,7 @@ static int r_main_r2pm_c(int argc, const char **argv) {
}
R2Pm r2pm = {0};
RGetopt opt;
r_getopt_init (&opt, argc, argv, "aqcdiIhH:flgrsuUv");
r_getopt_init (&opt, argc, argv, "aqcdiIhH:flgrpsuUv");
if (opt.ind < argc) {
// TODO: fully deprecate during the 5.9.x cycle
r2pm_actionword (&r2pm, argv[opt.ind]);
@ -790,6 +791,9 @@ static int r_main_r2pm_c(int argc, const char **argv) {
case 'd':
r2pm.doc = true;
break;
case 'p':
r2pm.plugdir = true;
break;
case 'I':
r2pm.info = true;
break;
@ -833,6 +837,18 @@ static int r_main_r2pm_c(int argc, const char **argv) {
break;
}
}
if (r2pm.plugdir) {
if (r2pm.clean) {
char *plugdir = r_xdg_datadir ("plugins");
if (R_STR_ISNOTEMPTY (plugdir)) {
r_file_rm_rf (plugdir);
free (plugdir);
}
} else {
R_LOG_ERROR ("-p requires -c");
return 1;
}
}
if (r2pm.init) {
r2pm_upgrade (r2pm.force);
}

View File

@ -5,7 +5,7 @@
.Nd radare2 package manager
.Sh SYNOPSIS
.Nm r2pm
.Op [adhHIiuUglsv]
.Op [adhHIipuUglsv]
.Op [pkg ...]
.Sh DESCRIPTION
Allows to install, update, uninstall and discover plugins and tools that can be used with radare2.
@ -34,6 +34,8 @@ List installed packages
Search in database for packages matching keyword
.It Fl r Ar command ...args
Run command with R2PM_BINDIR in PATH
.It Fl p
Requires -c to clean the R2PM_PLUGDIR
.It Fl v
Show version information
.It Fl h