Refactored class to have a main and a nailMain.
This commit is contained in:
parent
2ff8b02025
commit
ec6aed4e7f
@ -9,11 +9,13 @@
|
||||
|
||||
<target name="ng-deploy" depends="build">
|
||||
<!-- Stop the Nailgun Server -->
|
||||
<exec executable="cmd">
|
||||
<exec executable="cmd" os="">
|
||||
<arg value="/c"/>
|
||||
<arg value="ng-stop"/>
|
||||
</exec>
|
||||
|
||||
<exec executable="ng-stop" os="Linux"/>
|
||||
|
||||
<!-- delete old copies -->
|
||||
<delete>
|
||||
<fileset dir="${nailgun.classpath.dir}">
|
||||
@ -30,9 +32,11 @@
|
||||
</copy>
|
||||
|
||||
<!-- start the NG server up again. -->
|
||||
<exec executable="cmd">
|
||||
<exec executable="cmd" os="">
|
||||
<arg value="/c"/>
|
||||
<arg value="ng-start"/>
|
||||
</exec>
|
||||
|
||||
<exec executable="ng-start" os="Linux"/>
|
||||
</target>
|
||||
</project>
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user