diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ac33634 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build/ +.*.sw* diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..b6efbe6 --- /dev/null +++ b/build.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jdb-build-1.2.xml b/jdb-build-1.2.xml new file mode 100644 index 0000000..6a7cfce --- /dev/null +++ b/jdb-build-1.2.xml @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/compile/jar/twitter4j-core-2.1.7.jar b/lib/compile/jar/twitter4j-core-2.1.7.jar new file mode 100644 index 0000000..16ea2ab Binary files /dev/null and b/lib/compile/jar/twitter4j-core-2.1.7.jar differ diff --git a/lib/runtime/jar/twitter4j-core-2.1.7.jar b/lib/runtime/jar/twitter4j-core-2.1.7.jar new file mode 100644 index 0000000..16ea2ab Binary files /dev/null and b/lib/runtime/jar/twitter4j-core-2.1.7.jar differ diff --git a/project.properties b/project.properties new file mode 100644 index 0000000..ed95588 --- /dev/null +++ b/project.properties @@ -0,0 +1,6 @@ +#Fri, 05 Nov 2010 18:08:47 -0500 +lib.local=true +name=groovy-twitter-cli +version=0.1 +build.number=14 +nailgun.classpath.dir=C\:/Documents and Settings/jbernard/My Documents/ng-classpath diff --git a/src/com/jdbernard/twitter/TwitterCLI.groovy b/src/com/jdbernard/twitter/TwitterCLI.groovy new file mode 100644 index 0000000..40ef947 --- /dev/null +++ b/src/com/jdbernard/twitter/TwitterCLI.groovy @@ -0,0 +1,89 @@ +package com.jdbernard.twitter + +import twitter4j.Twitter +import twitter4j.TwitterFactory +import twitter4j.conf.Configuration +import twitter4j.conf.PropertyConfiguration + +public class TwitterCLI { + + static def twitter + + public static void main(String[] args) { + if (args.length < 1) printUsage() + + Configuration conf + File propFile = new File(System.getProperty("user.home"), ".groovy-twitter-cli-rc") + + propFile.withInputStream { is -> conf = new PropertyConfiguration(is) } + + twitter = (new TwitterFactory(conf)).getInstance() + + args = args as List + + switch (args[0].toLowerCase()) { + case ~/t.*/: timeline(args.tail()); break + case ~/p.*/: post(args.tail()); break + + default: + printUsage() + } + } + + void setColor(boolean bright, int code) { + print "\u001b[${bright?'1':'0'};${code}m" + } + + void resetColor() { print "\u001b[m" } + + void colorPrint(def message, boolean bright, int color) { + setColor(bright, color) + print message + resetColor() + } + + void colorPrintln(def message, boolean bright, int color) { + setColor(bright, color) + println message + resetColor() + } + + void timeline(List args) { + + // default to showing my friends timeline + if (args.size() == 0) args = ["friends"] + + while (args.size() > 0) { + def option = args.pop() + switch (option) { + // friends + case ~/f.*/: printTimeline(twitter.friendsTimeline); break + // mine + case ~/m.*/: printTimeline(twitter.userTimeline); break + // user + case ~/u.*/: + if (args.size() == 0) + colorPrintln("No user specificied.", true, 31) + else printTimeline(twitter.getUserTimeline(args.pop())) + break; + default: + colorPrint("Unknown timeline: ", true, 31) + colorPrintln(option, true, 33) + break; + } + } + } + + void printTimeline(def timeline) { + timeline.each { status -> + colorPrint(status.user.screenName, true, 34) + print ": " + println status.text + println "" + } + } + + void printUsage() { + // TODO + } +}