spm

Personal fork of spm (simple password manager)
git clone git@getsh.org:spm.git
Log | Files | Refs | README | LICENSE

commit 01f5b8ec9b51261ba8bd9217be46a1e7f0be2452
parent 604da370ce8131b43bef63483834eb6cb31b13e0
Author: Klemens Nanni <kl3@posteo.org>
Date:   Fri, 27 May 2016 01:58:23 +0200

Allow listing groups only with '-g'

Diffstat:
MREADME.md | 4++++
MREADME.pod | 9+++++++--
Mspm.sh | 13+++++++++----
3 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md @@ -39,6 +39,10 @@ List all entries of the group *system*: $ spm list system +List groups only: + + $ spm list -g + --- Also see my aliases in *.sh/spm* from my [dotfiles](https://notabug.org/kl3/dotfiles) repository for other diff --git a/README.pod b/README.pod @@ -4,7 +4,7 @@ spm - simple password manager =head1 SYNOPSIS -B<spm> I<COMMAND> [I<ENTRY>|I<GROUP>] +B<spm> I<COMMAND> [I<OPTION>] [I<ENTRY>|I<GROUP>] =head1 DESCRIPTION @@ -37,7 +37,8 @@ entries for example. spm I<list> followed by a directory path, that is a group name, lists all entries inside the specified group as well as all its subgroups. -If not name is given, all entries will be listed. +If not name is given, all entries will be listed. Passing I<-g> as +first parameter causes it to list groups only. spm I<help> prints information about how to use spm. @@ -105,6 +106,10 @@ List all entries of the group 'system': $ spm list system +List groups only: + + $ spm list -g + =head1 SEE ALSO git(1), gpg2(1), ln(1), pwgen(1), tpm(1), xclip(1) diff --git a/spm.sh b/spm.sh @@ -67,7 +67,7 @@ list() { [ -n "${1}" ] && [ ! -d "${STORE_DIR}/${1}" ] \ && die "No such group. See 'spm list'." - tree --noreport -l -C -- "${STORE_DIR}/${1}" \ + tree ${grps_only:+-d} --noreport -l -C -- "${STORE_DIR}/${1}" \ | sed "1s,${STORE_DIR}/,,; s,.gpg,,g" } @@ -98,16 +98,21 @@ show() { ## Parse input -[ ${#} -eq 0 ] || [ ${#} -gt 2 ] \ +[ ${#} -eq 0 ] || [ ${#} -gt 3 ] \ +|| [ ${#} -eq 3 ] && [ "${1}" != list ] \ && die "Invalid number of arguments. See 'spm help'." case "${1}" in - add|del|list|show) + add|del|show) ${1} "${2}" ;; + list) + [ "${2}" = -g ] && grps_only=1 && shift 1 + list "${2}" + ;; help) cat <<- EOF - USAGE: spm add|del|list|show|help [ENTRY|GROUP] + USAGE: spm add|del|list [-g]|show|help [ENTRY|GROUP] See spm(1) for more information. EOF