r2pm: handle info and install arguments properly (#14693)

This commit is contained in:
Ian Huang 2019-07-29 19:20:28 -07:00 committed by radare
parent ebb8374b01
commit 8248039e55
2 changed files with 24 additions and 20 deletions

View File

@ -405,8 +405,9 @@ pkgFilePath() {
} }
r2pm_doc() { r2pm_doc() {
if [ -z "$1" ]; then if [ -z "$2" ]; then
R2PM_Info echo "Usage: r2pm -d [package] # show docs on [package]"
exit 1
else else
FILE="$(pkgFilePath "$1")" FILE="$(pkgFilePath "$1")"
if [ -f "${FILE}" ]; then if [ -f "${FILE}" ]; then
@ -417,9 +418,6 @@ r2pm_doc() {
} }
r2pm_install() { r2pm_install() {
if [ -z "$2" ]; then
R2PM_Info
else
FILE="$(pkgFilePath "$2")" FILE="$(pkgFilePath "$2")"
if [ -f "${FILE}" ]; then if [ -f "${FILE}" ]; then
NAME="$2" NAME="$2"
@ -429,15 +427,15 @@ r2pm_install() {
R2PM_INSTALL R2PM_INSTALL
R2PM_REGISTER R2PM_REGISTER
else else
echo "Cannot find $FILE" echo "Cannot find $2"
exit 1 exit 1
fi fi
fi
} }
r2pm_uninstall() { r2pm_uninstall() {
if [ -z "$2" ]; then if [ -z "$2" ]; then
R2PM_Info echo "Usage: r2pm -u [package] # uninstall [package]"
exit 1
else else
FILE="`pkgFilePath $2`" FILE="`pkgFilePath $2`"
if [ -f "${FILE}" ]; then if [ -f "${FILE}" ]; then
@ -460,8 +458,14 @@ r2pm_uninstall() {
export PYTHON_PATH="${R2PM_PYPATH}:${PYTHON_PATH}" export PYTHON_PATH="${R2PM_PYPATH}:${PYTHON_PATH}"
case "$1" in case "$1" in
-I|info)
R2PM_Info
;;
-i|install) -i|install)
if [ "$2" = "all" ]; then if [ -z "$2" ]; then
echo "Usage: r2pm -i [package] # install [package]"
exit 1
elif [ "$2" = "all" ]; then
for a in `cd ${R2PM_DBDIR} && ls` ; do for a in `cd ${R2PM_DBDIR} && ls` ; do
r2pm_install "$a" r2pm_install "$a"
if [ "$?" != 0 ]; then if [ "$?" != 0 ]; then
@ -687,7 +691,7 @@ suicide)
cat <<HELP cat <<HELP
Usage: r2pm [init|update|cmd] [...] Usage: r2pm [init|update|cmd] [...]
Commands: Commands:
-i,info show information about a package -I,info information about repository and installed packages
-i,install <pkgname> install package in your home (pkgname=all) -i,install <pkgname> install package in your home (pkgname=all)
-gi,global-install <pkg> install package system-wide -gi,global-install <pkg> install package system-wide
-gu,global-uninstall <pkg> uninstall pkg from systemdir -gu,global-uninstall <pkg> uninstall pkg from systemdir

View File

@ -12,7 +12,7 @@ Allows to install, update, uninstall and discover plugins and tools that can be
.Bl -tag -width Fl .Bl -tag -width Fl
.It Fl a, Cm repo .It Fl a, Cm repo
Adds an external r2pm repository, no arguments to -a will list all the registered repos, use '-a - repo' to unregister/remove those repos. Adds an external r2pm repository, no arguments to -a will list all the registered repos, use '-a - repo' to unregister/remove those repos.
.It Fl i, Cm info .It Fl I, Cm info
Show information about repository and installed packages Show information about repository and installed packages
.It Fl i, Cm install Ar pkgname .It Fl i, Cm install Ar pkgname
Install a package Install a package