#!/bin/sh
set -eu


usage() {
	cat <<-'EOF'
		Usage:
		  tuivid FILE
		  tuivid -h
	EOF
}

help() {
	cat <<-'EOF'


		Options:
		  -h, --help    show this message

		  FILE          the name of the video file


		Play a video in the terminal, withut X or a GUI.


		Examples:

		  Play "movie.mp4":

		    $ tuivid movie.mp4
	EOF
}


for flag in "$@"; do
	case "$flag" in
		(--)
			break
			;;
		(--help)
			usage
			help
			exit
			;;
		(*)
			;;
	esac
done

while getopts 'h' flag; do
	case "$flag" in
		(h)
			usage
			help
			exit
			;;
		(*)
			usage >&2
			exit 2
			;;
	esac
done
shift $((OPTIND - 1))


exec mpv --quiet --vo=tct --vo-tct-256=yes --vo-tct-algo=plain --framedrop=vo "$@"
