From 846a81d4006e141a7667f459b25e76d769b8d3e9 Mon Sep 17 00:00:00 2001 From: shmibs Date: Tue, 28 Mar 2017 15:56:24 -0700 Subject: use zparseopts for options --- Readme.md | 10 ++-- make-gif | 202 ++++++++++++++++++++++++++------------------------------------ 2 files changed, 90 insertions(+), 122 deletions(-) diff --git a/Readme.md b/Readme.md index d905eb7..9ac951c 100644 --- a/Readme.md +++ b/Readme.md @@ -12,26 +12,26 @@ files as painless as possible, with support for things like embedding subtitles, various dithering algorithms, cropping, and post-optimisation (via [gifsicle](https://www.lcdf.org/gifsicle/)) -just clone and run `make-gif -h` to get started! +just clone and run `make-gif --help` to get started! examples ======== some example usages and their outputs: -`make-gif -o -s 36:18 -t 3 菊次郎の夏.mkv out.gif` +`make-gif -o -s 36:18 -l 3 菊次郎の夏.mkv out.gif` ![default](examples/default.gif) -`make-gif -or -s 36:18 -t 3 -c 64 -d bayer2 菊次郎の夏.mkv out.gif` +`make-gif -or -s 36:18 -l 3 -c 64 -d bayer2 菊次郎の夏.mkv out.gif` ![c-64_d-bayer2_r](examples/c-64_d-bayer2_r.gif) -`make-gif -o -s 36:18 -t 3 -c 8 -d bayer5 -f 15 -w 320 菊次郎の夏.mkv out.gif` +`make-gif -o -s 36:18 -l 3 -c 8 -d bayer5 -f 15 -w 320 菊次郎の夏.mkv out.gif` ![c-8_d-bayer5_f-15](examples/c-8_d-bayer5_f-15_w-320.gif) -`make-gif -o -s 16:21 -t 3.5 -b 0 'Christiane F.mkv' out.gif` +`make-gif -o -b -s 16:21 -l 3.5 'Christiane F.mkv' out.gif` ![subtitles](examples/subtitles.gif) diff --git a/make-gif b/make-gif index 7aa845e..582a312 100755 --- a/make-gif +++ b/make-gif @@ -1,28 +1,32 @@ #!/usr/bin/env zsh # export a clip from a video as a gif -local callstr="$0" -local hasgsic=$(whence gifsicle) +local callstr=$0 +local hasgsic + +[[ $(whence gifsicle) ]] && hasgsic=true print_error() { echo -e "\e[1;31merror:\e[0m $1\n" } usage() { - [[ "$1" != "" ]] && print_error $1 + [[ -z $1 ]] || print_error $1 echo "Usage: $callstr [OPTIONS...] " + echo "Create an animated gif from a video" echo "" - echo " description option default val" - echo " start time -s