diff options
author | Jonas Smedegaard <dr@jones.dk> | 2010-09-07 17:25:03 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2010-09-07 17:25:03 +0200 |
commit | d42f08caaed18dbef0d14528ad3c0a78cde35b90 (patch) | |
tree | 682b2d01df973b471e043f6460c6197e595f68b8 | |
parent | 08932f084ab06e8dfa4e8631c27d392c3eb62bd9 (diff) |
Add --help option; check number of parameters, check if input file exist.
-rwxr-xr-x | localvideowebencode | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/localvideowebencode b/localvideowebencode index cb4b2e1..1e4cc7e 100755 --- a/localvideowebencode +++ b/localvideowebencode @@ -9,19 +9,39 @@ set -e +PRG=$(basename "$0") + +showhelp() { + cat <<EOF +Usage: $PRG --size SIZE [--title TITLE] INPUTFILE +Encode video file in multiple web-optimized formats, and provide sample +html favoring open formats with optional non-JavaScript Flash fallback. + + -s, --size Output size in WIDTHxHEIGHT + (mandatory) + -t, --title Title used in html fallback graphics + (default: basename of input file) + -h, --help This help text + +Examples: + $PRG -s 320x200 -t "Funny guy" myvideo.dv + +More info: http://camendesign.com/code/video_for_everybody +EOF +} + exit1() { response="${1:+Error: }${1:-Internal error!}" echo >&2 "$response" exit 1 } -PRG=$(basename "$0") - # parse cmdline options -TEMP="`getopt -s sh -o s:t: -l size:,title: -n "$PRG" -- "$@"`" || exit1 "Internal getopt error." +TEMP="`getopt -s sh -o hs:t: -l help,size:,title: -n "$PRG" -- "$@"`" || exit1 "Internal getopt error." eval set -- "$TEMP" while true ; do case "$1" in + -h|--help) showhelp; exit;; -s|--size) size="$2"; shift 2;; -t|--title) title="$2"; shift 2;; --) shift; break;; @@ -29,8 +49,20 @@ while true ; do esac done +if [ $# -eq 0 ]; then + showhelp + exit1 "Too few parameters!" +fi + +if [ $# -gt 1 ]; then + showhelp + exit1 "Too many parameters!" +fi + # input filename (mandatory) -infile="$1"; shift || exit1 "Input file missing!" +infile="$1"; shift +[ -e "$infile" ] || exit1 "Input file missing!" + filebase=$(echo "$infile" | perl -pe 's/\.[^.]*//') # output size in WIDTHxHEIGHT (mandatory) |