-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
113 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,6 @@ | |
/.idea/workspace.xml | ||
/.idea/libraries | ||
/.idea/shelf | ||
/build | ||
build | ||
*.class | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apply plugin: 'application' | ||
|
||
version '1.0.0' | ||
mainClassName = 'com.widen.tabitha.runner.Runner' | ||
|
||
dependencies { | ||
compile project(':') | ||
compile 'commons-io:commons-io:2.5' | ||
compile 'org.codehaus.groovy:groovy-all:2.4.1' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.widen.tabitha.runner; | ||
|
||
import groovy.lang.GroovyShell; | ||
import org.apache.commons.io.IOUtils; | ||
import org.codehaus.groovy.control.CompilerConfiguration; | ||
import org.codehaus.groovy.control.customizers.ImportCustomizer; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
public class Runner | ||
{ | ||
private static File scriptFile; | ||
|
||
public static void main(String[] args) throws IOException | ||
{ | ||
for (String arg : args) | ||
{ | ||
if (arg.equals("-h") || arg.equals("--help") || arg.equals("-?") || arg.equals("/?")) | ||
{ | ||
printHelp(); | ||
return; | ||
} | ||
else | ||
{ | ||
scriptFile = new File(arg); | ||
break; | ||
} | ||
} | ||
|
||
execute(); | ||
} | ||
|
||
private static void printHelp() throws IOException | ||
{ | ||
InputStream inputStream = Runner.class.getClassLoader().getResourceAsStream("Help.txt"); | ||
String text = IOUtils.toString(inputStream, "UTF-8"); | ||
System.out.println(text); | ||
} | ||
|
||
private static void execute() throws IOException | ||
{ | ||
ImportCustomizer importCustomizer = new ImportCustomizer(); | ||
importCustomizer.addStarImports("com.widen.tabitha"); | ||
importCustomizer.addStarImports("com.widen.tabitha.formats"); | ||
importCustomizer.addStarImports("com.widen.tabitha.parallel"); | ||
|
||
CompilerConfiguration configuration = new CompilerConfiguration(); | ||
configuration.addCompilationCustomizers(importCustomizer); | ||
|
||
GroovyShell shell = new GroovyShell(configuration); | ||
shell.evaluate(scriptFile); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Tabitha Runner | ||
|
||
Usage: | ||
tabitha-runner [options] <script> | ||
|
||
Run a given Groovy script with Tabitha classes already available. | ||
|
||
Options: | ||
-h, --help Show this help message. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
include 'runner' | ||
|
||
rootProject.name = 'tabitha' | ||
project(':runner').name = 'tabitha-runner' |