Skip to content

Instantly share code, notes, and snippets.

@valvallow
Created December 22, 2016 14:37
Show Gist options
  • Save valvallow/ba073989f213437dd20006743428b34a to your computer and use it in GitHub Desktop.
Save valvallow/ba073989f213437dd20006743428b34a to your computer and use it in GitHub Desktop.
gosh repl tweet
#!/usr/local/bin/gosh
(use net.twitter)
(use gauche.parseopt)
(define (main args)
(let-args (cdr args)
((help "h|help" => (cut usage (car args)))
(consumer-key "consumer-key=s" "")
(consumer-secret "consumer-secret=s" "")
(access-token "access-token=s" "")
(access-token-secret "access-token-secret=s" "")
(else (opt . _)
(print "Unknown option : " opt)
(usage (car args)))
. rest)
(set-signal-handler! SIGINT (^ _ (exit)))
(let1 cred (make <twitter-cred>
:consumer-key consumer-key
:consumer-secret consumer-secret
:access-token access-token
:access-token-secret access-token-secret)
(print (twitter-update cred (if (null? rest)
(port->string (current-input-port))
(car rest)))))))
(define (usage cmd)
(print "Usage: " (sys-basename cmd) " [option ...] message or stdin")
(print " h|help : Show this help")
(print " consumer-key=s")
(print " consumer-secret=s")
(print " access-token=s")
(print " access-token-secret=s")
(exit))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment