summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/vtoc.sh19
1 files changed, 16 insertions, 3 deletions
diff --git a/bin/vtoc.sh b/bin/vtoc.sh
index fc69122..599e6ac 100755
--- a/bin/vtoc.sh
+++ b/bin/vtoc.sh
@@ -1,5 +1,16 @@
#!/bin/sh
+usage()
+{
+ cat <<- EOF
+ Usage: ${0##*/} [options] [ contacts.vcf ]
+ convert vcf file to csv file
+ Options:
+ -h show this help cruft
+
+ EOF
+}
+
die()
{
: "${1:?}"
@@ -23,9 +34,11 @@ no=
vcf=
nos=
-if [ -z "$1" ] ||
- [ "$(file --brief --dereference --mime-type "$1")" != "text/vcard" ]; then
- die "no or invalid input"
+if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
+ usage
+ exit
+elif [ "$(file --brief --dereference --mime-type "$1")" != "text/vcard" ]; then
+ die "input is not a vcf file"
else
vcf="$1"
shift