Browse Source

termux-api: Cleanups and fix whitespace handling

Fixes https://github.com/termux/termux-api/issues/20
android-5
Fredrik Fornwall 9 years ago
parent
commit
8d6e165f62
  1. 2
      packages/termux-api/build.sh
  2. 14
      packages/termux-api/termux-dialog
  3. 52
      packages/termux-api/termux-download
  4. 10
      packages/termux-api/termux-notification
  5. 2
      packages/termux-api/termux-sms-send

2
packages/termux-api/build.sh

@ -1,6 +1,6 @@
TERMUX_PKG_HOMEPAGE=http://termux.com/add-ons/api/ TERMUX_PKG_HOMEPAGE=http://termux.com/add-ons/api/
TERMUX_PKG_DESCRIPTION="Termux API commands" TERMUX_PKG_DESCRIPTION="Termux API commands"
TERMUX_PKG_VERSION=0.16 TERMUX_PKG_VERSION=0.17
termux_step_make_install () { termux_step_make_install () {
mkdir -p $TERMUX_PREFIX/bin mkdir -p $TERMUX_PREFIX/bin

14
packages/termux-api/termux-dialog

@ -6,10 +6,10 @@ show_usage () {
echo "Usage: $SCRIPTNAME [OPTIONS]" echo "Usage: $SCRIPTNAME [OPTIONS]"
echo "Show a text entry dialog." echo "Show a text entry dialog."
echo "" echo ""
echo " -i <hint> The input hint to show when the input is empty" echo " -i <hint> the input hint to show when the input is empty"
echo " -m Use a textarea with multiple lines instead of a single" echo " -m use a textarea with multiple lines instead of a single"
echo " -p Enter the input as a password" echo " -p enter the input as a password"
echo " -t <title> The title to show for the input prompt" echo " -t <title> the title to show for the input prompt"
exit 0 exit 0
} }
@ -37,4 +37,8 @@ shift $(($OPTIND-1))
if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
@TERMUX_API@ Dialog $ARG_I "$OPT_I" $ARG_M $ARG_P $ARG_T "$OPT_T" set -- $ARG_M $ARG_P
if [ -n "$ARG_I" ]; then set -- "$@" $ARG_I "$OPT_I"; fi
if [ -n "$ARG_T" ]; then set -- "$@" $ARG_T "$OPT_T"; fi
@TERMUX_API@ Dialog "$@"

52
packages/termux-api/termux-download

@ -1,30 +1,40 @@
#!/bin/sh #!/bin/sh
set -e -u set -e -u
SCRIPTNAME=$0 SCRIPTNAME=termux-download
show_usage () { show_usage () {
echo "usage: termux-download <uri-to-download>" echo "Usage: $SCRIPTNAME [OPTIONS] <url-to-download>"
echo " Download a resource using the system download manager." echo "Download a resource using the system download manager."
echo " -d, --description Description for the download request notification" echo ""
echo " -t, --title Title for the download request notification" echo " -d <description> description for the download request notification"
echo " -t <title> title for the download request notification"
exit 0
} }
PARAMS="" ARG_D=""
O=`busybox getopt -q -l description: -l title: -l help -- d:t:h "$@"` OPT_D=""
if [ $? != 0 ] ; then show_usage; exit 1 ; fi ARG_T=""
eval set -- "$O" OPT_T=""
while true; do
case "$1" in while getopts :hd:t: option
-h|--help) show_usage; exit 0;; do
-d|--description) PARAMS="$PARAMS --es description '$2'"; shift 2;; case "$option" in
-t|--title) PARAMS="$PARAMS --es title '$2'"; shift 2;; h) show_usage;;
--) shift; break;; d) ARG_D="--es description"; OPT_D="$OPTARG";;
*) echo Error; exit 1;; t) ARG_T="--es title"; OPT_T="$OPTARG";;
esac ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1;
esac
done done
shift $(($OPTIND-1))
if [ $# -lt 1 ]; then echo "$SCRIPTNAME: no url specified"; exit 1; fi
if [ $# -gt 1 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
URL_TO_DOWNLOAD="$1"
# Too many arguments: set --
if [ $# != 1 ]; then show_usage; exit 1; fi if [ -n "$ARG_D" ]; then set -- "$@" $ARG_D "$OPT_D"; fi
if [ -n "$ARG_T" ]; then set -- "$@" $ARG_T "$OPT_T"; fi
set -- "$@" $URL_TO_DOWNLOAD
eval @TERMUX_API@ Download $PARAMS $1 @TERMUX_API@ Download "$@"

10
packages/termux-api/termux-notification

@ -3,7 +3,7 @@ set -e -u
SCRIPTNAME=termux-notification SCRIPTNAME=termux-notification
show_usage () { show_usage () {
echo "usage: termux-notification [OPTIONS]" echo "Usage: termux-notification [OPTIONS]"
echo "Display a system notification." echo "Display a system notification."
echo "" echo ""
echo " -c <content> notification content to show" echo " -c <content> notification content to show"
@ -43,4 +43,10 @@ if [ $CONTENT_OR_TITLE_SET = "no" ]; then
exit 1 exit 1
fi fi
@TERMUX_API@ Notification $ARG_C "$OPT_C" $ARG_I "$OPT_I" $ARG_T "$OPT_T" $ARG_U "$OPT_U" set --
if [ -n "$ARG_C" ]; then set -- "$@" $ARG_C "$OPT_C"; fi
if [ -n "$ARG_I" ]; then set -- "$@" $ARG_I "$OPT_I"; fi
if [ -n "$ARG_T" ]; then set -- "$@" $ARG_T "$OPT_T"; fi
if [ -n "$ARG_U" ]; then set -- "$@" $ARG_U "$OPT_U"; fi
@TERMUX_API@ Notification "$@"

2
packages/termux-api/termux-sms-send

@ -6,7 +6,7 @@ show_usage () {
echo "Usage: $SCRIPTNAME [-t <text>] <recipient-number>" echo "Usage: $SCRIPTNAME [-t <text>] <recipient-number>"
echo "Send a SMS." echo "Send a SMS."
echo "" echo ""
echo " -t <text> The text to send (optional - else from stdin)" echo " -t <text> text to send (optional - else from stdin)"
echo "" echo ""
echo "If no text is specified with the -t option the text to send is read from stdin." echo "If no text is specified with the -t option the text to send is read from stdin."
exit 0 exit 0

Loading…
Cancel
Save