mirror of
https://github.com/GTNewHorizons/CodeChickenCore.git
synced 2026-11-11 07:47:47 +00:00
Added command line tool frontend.
This commit is contained in:
1 parent
7450370d99
commit
ae652f51c2
9 files changed
+396
-23
No files matched your search
@@ -0,0 +1,48 @@
|
||||
package codechicken.lib.tool.module;
|
||||
|
||||
import codechicken.lib.tool.ToolMain;
|
||||
import joptsimple.OptionException;
|
||||
import joptsimple.OptionParser;
|
||||
import joptsimple.OptionSet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public abstract class JOptModule implements ToolMain.Module
|
||||
{
|
||||
OptionParser parser = new OptionParser();
|
||||
|
||||
@Override
|
||||
public void main(String[] args) {
|
||||
OptionSet options;
|
||||
try
|
||||
{
|
||||
options = parser.parse(args);
|
||||
}
|
||||
catch(OptionException ex)
|
||||
{
|
||||
System.err.println(ex.getLocalizedMessage());
|
||||
System.exit(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
main(parser, options);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void main(OptionParser parser, OptionSet options);
|
||||
|
||||
@Override
|
||||
public void printHelp() {
|
||||
try {
|
||||
parser.printHelpOn(System.out);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user