diff --git a/build.xml b/build.xml index b6efbe6..8b3ac42 100644 --- a/build.xml +++ b/build.xml @@ -9,11 +9,13 @@ - + + + @@ -30,9 +32,11 @@ - + + + diff --git a/project.properties b/project.properties index ed95588..844e923 100644 --- a/project.properties +++ b/project.properties @@ -1,6 +1,7 @@ -#Fri, 05 Nov 2010 18:08:47 -0500 +#Sat, 06 Nov 2010 10:35:28 -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 +build.number=19 +nailgun.classpath.dir=/home/jdbernard/programs/nailgun/classpath +win32.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 index 40ef947..fe9afe3 100644 --- a/src/com/jdbernard/twitter/TwitterCLI.groovy +++ b/src/com/jdbernard/twitter/TwitterCLI.groovy @@ -7,19 +7,55 @@ import twitter4j.conf.PropertyConfiguration public class TwitterCLI { - static def twitter + private static TwitterCLI nailgunInst + private Twitter twitter public static void main(String[] args) { - if (args.length < 1) printUsage() + TwitterCLI inst = new TwitterCLI(new File(System.getProperty("user.home"), + ".groovy-twitter-cli-rc")) + inst.run(args as List) + } + + public static void nailMain(String[] args) { + + if (nailgunInst == null) nailgunInst = new TwitterCLI(new File( + System.getProperty("user.home"), ".groovy-twitter-cli-rc")) + + nailgunInst.run(args as List) + } + + public static void setColor(boolean bright, int code) { + print "\u001b[${bright?'1':'0'};${code}m" + } + + public static void resetColor() { print "\u001b[m" } + + public static void colorPrint(def message, boolean bright, int color) { + setColor(bright, color) + print message + resetColor() + } + + public static void colorPrintln(def message, boolean bright, int color) { + setColor(bright, color) + println message + resetColor() + } + + public TwitterCLI(File propFile) { + + // load the configuration Configuration conf - File propFile = new File(System.getProperty("user.home"), ".groovy-twitter-cli-rc") - propFile.withInputStream { is -> conf = new PropertyConfiguration(is) } + // create a twitter instance twitter = (new TwitterFactory(conf)).getInstance() - args = args as List + } + + public void run(List args) { + if (args.size() < 1) printUsage() switch (args[0].toLowerCase()) { case ~/t.*/: timeline(args.tail()); break @@ -28,27 +64,10 @@ public class TwitterCLI { 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) { + public void timeline(List args) { // default to showing my friends timeline if (args.size() == 0) args = ["friends"] @@ -83,7 +102,7 @@ public class TwitterCLI { } } - void printUsage() { + public static void printUsage() { // TODO } }