dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit 8410dee006f1613c8af9673c069875102b2d775e
parent fb4702590523d2b9835a59b9417a90b10d8c70c5
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Sun, 10 Nov 2019 21:28:05 +0100

Add --verbose option and only display URL by default

Diffstat:
M.local/bin/upload | 33++++++++++++++++++++++++++-------
1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/.local/bin/upload b/.local/bin/upload @@ -13,10 +13,12 @@ show_help() { echo "will upload each FILE to $user@$host:$remotedir" echo "If no FILE is specified, this program will expect stdin, and FILE1" echo "will be used as the filename during upload." + echo "The program prints the upload URL for each file to standard output" echo echo "OPTIONS are one or more of the following:" echo " -h, --help show this message" - echo " -v, --version show version and license information" + echo " -V, --version show version and license information" + echo " -v, --verbose show verbose information (e.g. upload progress)" echo " -n, --notify also show diagnostic output with notify-send" echo " -- do not consider any following arguments as options" echo " -b, --border if an image, add a 10% white border to FILES" @@ -80,12 +82,22 @@ upload_file() { infile="$1" basename="$2" newbasename="$(echo "$basename" | sed 's/ /_/g')" - rsync -rvz --progress --chmod=Fu=rw,Fog=r -e "ssh" "$infile" \ - "${user}@${host}:${remotedir}/$newbasename" + progress="" + if [ "$verbose" = 1 ]; then + progress="-v --progress" + echo "infile: $infile" + echo "newbasename: $newbasename" + fi + rsync -rz $progress --chmod=Fu=rw,Fog=r -e "ssh" "$infile" \ + "${user}@${host}:${remotedir}/'$newbasename'" url="https://$host/files_nonpub/${newbasename}" - echo - msg="Uploaded to $url (copied to clipboard)" - printf "%s\n" "$msg" + if [ "$verbose" = 1 ]; then + echo + msg="Uploaded to $url (copied to clipboard)" + printf "%s\n" "$msg" + else + printf "%s\n" "$url" + fi [ "$notify" = 1 ] && notify-send "$msg" if [ "$(uname)" = "Darwin" ]; then @@ -118,16 +130,20 @@ resize=0 sharpen=0 get=0 delete=0 +verbose=0 while :; do case "$1" in -h|-\?|--help) show_help exit 0 ;; - -v|--version) + -V|--version) show_version exit 0 ;; + -v|--verbose) + verbose=1 + ;; -n|--notify) notify=1 ;; @@ -181,6 +197,9 @@ if [ "$get" = 1 ] || [ "$delete" = 1 ]; then fi else if [ ! -f "$1" ]; then + if [ $verbose = 1 ]; then + echo "reading from stdin..." + fi msg="$(cat)" tempfile="$(mktemp)" printf "%s" "$msg" > "$tempfile"