From f432246cdd3a1a042acdaa0f6696730b98991f41 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Fri, 30 Jun 2023 12:15:42 +0530 Subject: vtoc: add usage and -h option --- bin/vtoc.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'bin') 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 -- cgit v1.2.3