You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

imgur 997B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env elvish
  2. resp = [&]
  3. id = (from-json <~/sns/imgur.json)[SolitudeAnon][id]
  4. command = [-sLX POST 'https://api.imgur.com/3/image' --data-binary '@-' -H "Authorization: Client-ID "$id ]
  5. argn = (count $args)
  6. if (and (> $argn 0) (eq $args[0] -d)) {
  7. if (== $argn 1) {
  8. echo Provide deletion hash
  9. exit 1
  10. }
  11. resp = (curl -sLX DELETE 'https://api.imgur.com/3/image/'$args[1] -H \
  12. 'Authorization: Client-ID '$id | from-json)
  13. if (and (has-key $resp success) (eq $resp[success] $true)) {
  14. echo Image deleted
  15. } else {
  16. echo Failed to delete image
  17. exit 1
  18. }
  19. } else {
  20. if (not-eq ?(tty -s) $ok) {
  21. resp = (all | base64 | curl $@command | from-json)
  22. } elif (> $argn 0) {
  23. resp = (base64 $args[0] | curl $@command | from-json)
  24. } else {
  25. exit 1
  26. }
  27. if (and (has-key $resp success) (eq $resp[success] $true)) {
  28. echo Uploaded to $resp[data][link]
  29. echo Delete hash: $resp[data][deletehash]
  30. } else {
  31. echo Upload failed
  32. exit 1
  33. }
  34. }