Mercurial > paster
comparison paster.sh @ 48:fa7125489435
paster: make private pastes by default, closes #2481
author | David Demelier <markand@malikania.fr> |
---|---|
date | Fri, 14 Feb 2020 20:10:00 +0100 |
parents | 39defd15564e |
children | 78a4062bed62 |
comparison
equal
deleted
inserted
replaced
47:ad092d8050d2 | 48:fa7125489435 |
---|---|
18 | 18 |
19 author="Anonymous" | 19 author="Anonymous" |
20 language="nohighlight" | 20 language="nohighlight" |
21 title="Untitled" | 21 title="Untitled" |
22 duration="month" | 22 duration="month" |
23 private=0 | 23 public=0 |
24 verbose=0 | 24 verbose=0 |
25 | 25 |
26 die() | 26 die() |
27 { | 27 { |
28 echo "$@" 1>&2 | 28 echo "$@" 1>&2 |
221 } | 221 } |
222 | 222 |
223 usage() | 223 usage() |
224 { | 224 { |
225 cat 1>&2 <<-EOF | 225 cat 1>&2 <<-EOF |
226 usage: paster [-LDvx] [-a author] [-l language] [-d duration] [-t title] filename host | 226 usage: paster [-LDpv] [-a author] [-l language] [-d duration] [-t title] filename host |
227 EOF | 227 EOF |
228 exit 1 | 228 exit 1 |
229 } | 229 } |
230 | 230 |
231 send() | 231 send() |
232 { | 232 { |
233 if [ $private -eq 1 ]; then | 233 if [ $public -eq 1 ]; then |
234 with_private="--data private=off" | |
235 else | |
234 with_private="--data private=on" | 236 with_private="--data private=on" |
235 fi | 237 fi |
238 | |
236 if [ $verbose -eq 0 ]; then | 239 if [ $verbose -eq 0 ]; then |
237 with_verbose="-s" | 240 with_verbose="-s" |
238 fi | 241 fi |
239 | 242 |
240 curl -i -X POST \ | 243 curl -i -X POST \ |
250 | 253 |
251 if ! command -v curl >/dev/null 2>&1; then | 254 if ! command -v curl >/dev/null 2>&1; then |
252 die "abort: curl is required" | 255 die "abort: curl is required" |
253 fi | 256 fi |
254 | 257 |
255 while getopts "LDa:d:l:t:vx" opt; do | 258 while getopts "LDa:d:l:pt:v" opt; do |
256 case "$opt" in | 259 case "$opt" in |
257 D) | 260 D) |
258 durations | 261 durations |
259 ;; | 262 ;; |
260 L) | 263 L) |
267 duration="$OPTARG" | 270 duration="$OPTARG" |
268 ;; | 271 ;; |
269 l) | 272 l) |
270 language="$OPTARG" | 273 language="$OPTARG" |
271 ;; | 274 ;; |
275 p) | |
276 public=1 | |
277 ;; | |
272 t) | 278 t) |
273 title="$OPTARG" | 279 title="$OPTARG" |
274 ;; | 280 ;; |
275 v) | 281 v) |
276 verbose=1 | 282 verbose=1 |
277 ;; | |
278 x) | |
279 private=1 | |
280 ;; | 283 ;; |
281 *) | 284 *) |
282 usage | 285 usage |
283 ;; | 286 ;; |
284 esac | 287 esac |