spm

simple password manager
git clone anongit@rnpnr.xyz:spm.git
Log | Files | Refs | Feed | README | LICENSE

Commit: 135cf33b05e2cbb7746412c05848b63596062352
Parent: 2f2dc9996d98164ad7acd2bc8b0e690b97216cf1
Author: Klemens Nanni
Date:   Sat, 27 Feb 2016 19:44:57 +0100

List entries on list command

Diffstat:
MREADME.pod | 10+++++++---
Mtpm | 18++++++++++++------
2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/README.pod b/README.pod @@ -4,7 +4,7 @@ tpm - tiny password manager =head1 SYNOPSIS -B<tpm> [I<COMMAND> [I<ENTRY>]] +B<tpm> I<COMMAND> [I<ENTRY>|I<GROUP>] =head1 DESCRIPTION @@ -19,8 +19,9 @@ I<show> and supplying one entry as a target. If I<insert> is specified as a command tpm will create a new entry and prompt for the corresponding password. If you specify I<show> as a command tpm will write the password for the given entry to standard output. Specifying -I<help> as command without entry will show how to use tpm. Running tpm -without any commands lists all existing entries in a tree structure. +I<help> as command without entry will show how to use tpm. The command +I<list> will list all entries in the group I<group>. If I<group> is +omitted, all entries of all groups will be listed. =head1 ENVIRONMENT @@ -68,6 +69,9 @@ Copy your 'system/root' password to the clipboard using xclip(1): $ tpm show system/root | tr -d '\n' | xclip +List all entries of the group 'system': + $ tpm list system + =head1 SEE ALSO gpg2(1), pass(1), pwgen(1), xclip(1) diff --git a/tpm b/tpm @@ -53,12 +53,18 @@ readpw() { } usage() { - echo "USAGE: tpm (show|insert|help) [ENTRY]" + echo "USAGE: tpm (show|insert|list|help) [ENTRY|GROUP]" } -all() { +list() { [ -d "${STORE_DIR}" ] || mkdir -p "${STORE_DIR}" - tree --prune --noreport "${STORE_DIR}" + + echo "${1}" + if [ -n "${1}" ] && [ ! -d "${STORE_DIR}/${1}" ]; then + abort "The specified group doesn't exist. See 'tpm list'." + fi + + tree --prune --noreport "${STORE_DIR}/${1}" echo } @@ -123,12 +129,12 @@ case "${1}" in "insert") insert "${2}" ;; + "list") + list "${2}" + ;; "help") usage ;; - "") - all - ;; *) abort "You didn't specify a valid command. See 'tpm help'." ;;