commit ff7f52a65cd6eaceff7393dd78358eff98e11614
parent 7c9c6c3c17e75d9b4506b0128d827c45e32a2a4a
Author: Klemens Nanni <kl3@posteo.org>
Date: Sat, 27 Feb 2016 17:45:01 +0100
Add help command and usage function
Diffstat:
2 files changed, 11 insertions(+), 3 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>]
=head1 DESCRIPTION
@@ -18,7 +18,8 @@ Invoking tpm consists of specifying a command either I<insert> or
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.
+write the password for the given entry to standard output. Specifying
+I<help> as command without entry will show how to use tpm.
=head1 ENVIRONMENT
diff --git a/tpm b/tpm
@@ -52,6 +52,10 @@ readpw() {
[ -t 0 ] && stty echo
}
+usage() {
+ echo "USAGE: tpm (show|insert|help) [ENTRY]"
+}
+
##
# Commands
##
@@ -113,8 +117,11 @@ case "${1}" in
"insert")
insert "${2}"
;;
+ "help")
+ usage
+ ;;
*)
- abort "USAGE: tpm COMMAND ENTRY"
+ abort "You didn't specify a command. See 'tpm help'."
;;
esac