termux-api: Start to cleanup api calling scripts
[termux-packages] / packages / termux-api / termux-clipboard-set
1 #!/bin/sh
2 set -e -u
3
4 SCRIPTNAME=termux-clipboard-set
5 show_usage () {
6 echo "Usage: $SCRIPTNAME <text>"
7 echo "Set the system clipboard text."
8 echo ""
9 echo "If no arguments are given the text to set is read from stdin,"
10 echo "otherwise all arguments given are used as the text to set."
11 exit 0
12 }
13
14 while getopts :h option
15 do
16 case "$option" in
17 h) show_usage;;
18 ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
19 esac
20 done
21 shift $(($OPTIND-1))
22
23 CMD="@TERMUX_API@ Clipboard -e api_version 2 --ez set true"
24 if [ $# = 0 ]; then
25 $CMD
26 else
27 echo $@ | $CMD
28 fi
29