termux-api: Start to cleanup api calling scripts
[termux-packages] / packages / termux-api / termux-camera-photo
... / ...
CommitLineData
1#!/bin/sh
2
3set -e -u
4
5show_usage () {
6 echo "usage: termux-camera-photo [OPTIONS] <output-file>"
7 echo ""
8 echo "Take a photo and save it in a file. Valid options:"
9 echo " -c, --camera <camera-id> the ID of the camera to use"
10 echo "Use termux-camera-info for information about available camera IDs."
11}
12
13PARAMS=""
14O=`getopt -l camera: -l help -l size -- c:hs: "$@"`
15eval set -- "$O"
16while true; do
17case "$1" in
18 -c|--camera) PARAMS="$PARAMS --es camera $2"; shift 2;;
19 -h|--help) show_usage; exit 0;;
20 -s|--size) PARAMS="$PARAMS --ei size_index $2"; shift 2;;
21 --) shift; break;;
22 *) echo Error; exit 1;;
23esac
24done
25
26if [ $# != 1 ]; then show_usage; exit 1; fi
27
28touch $1
29PARAMS="$PARAMS --es file `realpath $1`"
30
31@TERMUX_API@ CameraPhoto $PARAMS