termux-api: Cleanup and improve consistency
[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. The text to set is either supplied as arguments or read from stdin if no arguments are given."
8 echo ""
9 exit 0
10 }
11
12 while getopts :h option
13 do
14 case "$option" in
15 h) show_usage;;
16 ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
17 esac
18 done
19 shift $(($OPTIND-1))
20
21 CMD="@TERMUX_API@ Clipboard -e api_version 2 --ez set true"
22 if [ $# = 0 ]; then
23 $CMD
24 else
25 echo $@ | $CMD
26 fi
27