diff options
| author | clsr <clsr@clsr.net> | 2016-11-16 20:38:58 +0100 | 
|---|---|---|
| committer | clsr <clsr@clsr.net> | 2016-11-16 20:38:58 +0100 | 
| commit | f909ab3cd1487bc463ea10e0ec9df54cdc99edee (patch) | |
| tree | 2b9da2160fbb34d36fbdbd19ec9c8e526ef57f00 | |
| parent | 0b216fe7a35a3d0e19bcbfb96019cd0fe5829b64 (diff) | |
| download | gomf-tools-f909ab3cd1487bc463ea10e0ec9df54cdc99edee.tar.gz gomf-tools-f909ab3cd1487bc463ea10e0ec9df54cdc99edee.zip | |
Add --service flag to gomfload.sh
| -rwxr-xr-x | gomfload.sh | 30 | 
1 files changed, 28 insertions, 2 deletions
| diff --git a/gomfload.sh b/gomfload.sh index d3963f9..77dcbed 100755 --- a/gomfload.sh +++ b/gomfload.sh @@ -6,7 +6,7 @@  # requires: POSIX sh, curl, tr -host="${GOMF_HOST:-https://example.com/}" +service="${GOMF_HOST:-https://example.com/}"  prog="$(basename "$0")"  stdin=1 @@ -15,6 +15,14 @@ usage() {  	printf "Usage: %s < file\n" "$prog"  	printf "       command | %s\n" "$prog"  	printf "       %s file1 file2 file3 ...\n" "$prog" +	printf "\n" +	printf "Options (applies for all files following the flag):\n" +	printf "  -S,  --service=ADDR  uses ADDR as the service URL\n" +	printf "  -h,  --help          display this help and exit\n" +	printf "  --                   stop processing options and treat all following arguments as filenames\n" +	printf "\n" +	printf "Example: %s foo -lsh bar -u baz -p quux -L qwe asd\n" "$prog" +	printf "  will post 'foo' and 'baz' as files, 'bar' and 'quux' as .sh pastes and 'qwe' and 'asd' as raw pastes\n"  	exit  } @@ -26,7 +34,7 @@ upload() {  			file=";filename=$filename"  		fi  	fi -	url="$(curl --progress-bar -F "files[]=@-$file" "${host%/}/upload.php?output=gyazo")" +	url="$(curl --progress-bar -F "files[]=@-$file" "${service%/}/upload.php?output=gyazo")"  	case "$url" in  		http*)  			printf "%s\n" "$url" @@ -56,6 +64,24 @@ while [ $# -gt 0 ]; do  			usage  			;; +		-S|--service) +			if [ $# -ge 2 ]; then +				service="$2" +				shift +			else +				printf "%s: option '%s' requires an argument\n" "$prog" "$1" >&2 +				exit 2 +			fi +			;; + +		-S?*) +			service="${1#-S}" +			;; + +		--service=*) +			service="${1#*=}" +			;; +  		--)  			shift  			break |