spm

Personal fork of spm (simple password manager)

commit f337aad6c3b740ffe16972d39db54f9a984f40f8
parent ff7f52a65cd6eaceff7393dd78358eff98e11614
Author: Klemens Nanni <kl3@posteo.org>
Date: Sat, 27 Feb 2016 18:33:20 +0100

List all entries when no command is given
2 files changed, 13 insertions(+), 3 deletions(-)
M
README.pod
|
5
+++--
M
tpm
|
11
++++++++++-
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>]]
 
 =head1 DESCRIPTION
 

@@ -19,7 +19,8 @@ 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.
+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.
 
 =head1 ENVIRONMENT
 
diff --git a/tpm b/tpm
@@ -56,6 +56,12 @@ usage() {
   echo "USAGE: tpm (show|insert|help) [ENTRY]"
 }
 
+all() {
+  [ -d "${STORE_DIR}" ] || mkdir -p "${STORE_DIR}"
+  tree --prune --noreport "${STORE_DIR}"
+  echo
+}
+
 ##
 # Commands
 ##

@@ -120,8 +126,11 @@ case "${1}" in
   "help")
     usage
     ;;
+  "")
+    all
+    ;;
   *)
-    abort   "You didn't specify a command. See 'tpm help'."
+    abort   "You didn't specify a valid command. See 'tpm help'."
     ;;
 esac