From b1927c415d27d93ea3dfb79d7050315a0516c6a7 Mon Sep 17 00:00:00 2001 From: JLKwong <61807745+JLKwong@users.noreply.github.com> Date: Fri, 5 Mar 2021 19:08:58 -0800 Subject: [PATCH] `treehouses camera` refactor (fixes #2061) (#2064) Co-authored-by: dogi --- modules/camera.sh | 13 +++++++------ package.json | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/camera.sh b/modules/camera.sh index 609de65b4..b5a1f4e74 100644 --- a/modules/camera.sh +++ b/modules/camera.sh @@ -60,19 +60,19 @@ function camera { if ! grep -q "start_x=1" ${config} ; then log_and_exit1 "Error: you need to enable AND reboot first in order to take pictures." fi - case "$2" in + case "$2" in "") echo "Camera is recording ${length} seconds of video and storing a time-stamped ${vidtype} video in ${viddir}." let length=$length*1000 raspivid -o "${viddir}$BASENAME-${timestamp}.h264" -t "${length}" && echo "Success: Video captured" && echo "Converting video to ${vidtype}" convert ${viddir}$BASENAME-${timestamp}.h264 ${viddir}$BASENAME-${timestamp}.${vidtype} rm ${viddir}$BASENAME-${timestamp}.h264 - ;; - + ;; + *) if ! [[ "$2" =~ ^[1-9][0-9]*$ ]] ; then #^[0-9]+$ to accept 0 for indefinite recording log_and_exit1 "Error: positive integers only." - else + else echo "Camera is recording ${2} seconds of video and storing a time-stamped ${vidtype} video in ${viddir}." let length=$2*1000 raspivid -o "${viddir}$BASENAME-${timestamp}.h264" -t "${length}" && echo "Success: Video captured" && echo "Converting video to ${vidtype}" @@ -82,7 +82,7 @@ function camera { ;; esac ;; - + "detect") mkdir -p ${directory} if ! grep -q "start_x=1" ${config} ; then @@ -113,7 +113,8 @@ function camera { fi ;; - "*") + *) + echo "Error: The only supported options are 'on', 'off', 'detect, 'capture', and 'record'." camera_help ;; esac diff --git a/package.json b/package.json index 032fabb63..52c3b8c78 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@treehouses/cli", - "version": "1.25.12", + "version": "1.25.13", "remote": "4000", "description": "Thin command-line interface for Raspberry Pi low level configuration.", "main": "cli.sh",