From cafdd18c27161c9396b37725405853f2b046c8eb Mon Sep 17 00:00:00 2001 From: pancake Date: Sun, 28 Feb 2021 17:59:07 +0100 Subject: [PATCH] Fix #18391 - Show help in r2pm even before initializing the db ##tools --- binr/r2pm/r2pm | 90 +++++++++++++++++++++++++++++++------------------- 1 file changed, 56 insertions(+), 34 deletions(-) diff --git a/binr/r2pm/r2pm b/binr/r2pm/r2pm index 551bfac1dd..ec3dca4bcd 100755 --- a/binr/r2pm/r2pm +++ b/binr/r2pm/r2pm @@ -120,6 +120,42 @@ if [ -f "d/baleful" ]; then R2PM_DBDIR="$(pwd)/d/" fi +help() { + cat < install or update package in your home (pkgname=all) + -gi,global-install install or update package system-wide + -gu,global-uninstall uninstall pkg from systemdir + -u,uninstall r2pm -u baleful (-uu to force) + -l,list list installed pkgs + -r,run [cmd ...args] run shell command with R2PM_BINDIR in PATH + -s,search [] search in database + -t,test FX,XX,BR BID check in Travis regressions + -v,version show version + -h,help show this message + -H variable show value of given variable + -c,clean ([git/dir]) clear source cache (GITDIR) + -ci (pkgname) clean install of given package + -cp clean the user's home plugin directory + -d,doc [pkgname] show documentation for given package + -w what/where is installed + init | update .. initialize/update database + cd [git/dir] cd into given git (see 'r2pm ls') + ls ls all cloned git repos in GITDIR + suicide self remove all (home + system) installations of r2 + cache cache contents of r2 -H to make r2pm r2-independent +Environment: + SUDO=sudo use this tool as sudo + R2PM_PLUGDIR=${R2PM_PLUGDIR} + R2PM_BINDIR=${R2PM_BINDIR} + R2PM_DBDIR=${R2PM_DBDIR} + R2PM_GITDIR=${R2PM_GITDIR} + R2PM_GITSKIP=${R2PM_GITSKIP} +HELP +} + confirm() { printf "$@ (y/N)? " read A @@ -215,8 +251,26 @@ init|up|update) exit 0 ;; esac + +# commandline flags that work without initialized database +case "$1" in +-v|version) + echo "r2pm ${R2_VERSION}" + ;; +help|-h) + help + ;; +-H) + if [ -z "$2" ]; then + echo "Usage: r2pm -H [VARNAME]" + echo "Variables: R2PM_PLUGDIR R2PM_BINDIR R2PM_DBDIR R2PM_GITDIR" + exit 1 + fi + eval echo "\$$2" + ;; +esac + if [ ! -d "${R2PM_DBDIR}" ]; then - echo '$R2PM_DBDIR: No such file or directory.' echo "Run 'r2pm init' to initialize the package repository" exit 1 fi @@ -713,38 +767,6 @@ suicide) r2pm_doc "$2" ;; *|help|-h) - cat < install or update package in your home (pkgname=all) - -gi,global-install install or update package system-wide - -gu,global-uninstall uninstall pkg from systemdir - -u,uninstall r2pm -u baleful (-uu to force) - -l,list list installed pkgs - -r,run [cmd ...args] run shell command with R2PM_BINDIR in PATH - -s,search [] search in database - -t,test FX,XX,BR BID check in Travis regressions - -v,version show version - -h,help show this message - -H variable show value of given variable - -c,clean ([git/dir]) clear source cache (GITDIR) - -ci (pkgname) clean install of given package - -cp clean the user's home plugin directory - -d,doc [pkgname] show documentation for given package - -w what/where is installed - init | update .. initialize/update database - cd [git/dir] cd into given git (see 'r2pm ls') - ls ls all cloned git repos in GITDIR - suicide self remove all (home + system) installations of r2 - cache cache contents of r2 -H to make r2pm r2-independent -Environment: - SUDO=sudo use this tool as sudo - R2PM_PLUGDIR=${R2PM_PLUGDIR} - R2PM_BINDIR=${R2PM_BINDIR} - R2PM_DBDIR=${R2PM_DBDIR} - R2PM_GITDIR=${R2PM_GITDIR} - R2PM_GITSKIP=${R2PM_GITSKIP} -HELP + help ;; esac