mirror of
https://github.com/GTNewHorizons/CodeChickenCore.git
synced 2026-11-16 01:54:50 +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,44 @@
|
||||
package codechicken.lib.tool;
|
||||
|
||||
import codechicken.lib.tool.module.ModuleQBConverter;
|
||||
|
||||
public class ToolMain
|
||||
{
|
||||
public static interface Module {
|
||||
public void main(String[] args);
|
||||
public String name();
|
||||
public void printHelp();
|
||||
}
|
||||
|
||||
public static Module[] modules = new Module[]{
|
||||
new ModuleQBConverter()
|
||||
};
|
||||
|
||||
private static void printHelp() {
|
||||
System.out.println("Usage: [module] [args]");
|
||||
System.out.println(" Modules: ");
|
||||
for(Module m : modules)
|
||||
System.out.println(" - "+m.name());
|
||||
System.out.println("-h [module] for module help");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
if(args.length > 0) {
|
||||
for(Module m : modules)
|
||||
if(args[0].equals(m.name())) {
|
||||
String[] args2 = new String[args.length-1];
|
||||
System.arraycopy(args, 1, args2, 0, args2.length);
|
||||
m.main(args2);
|
||||
return;
|
||||
}
|
||||
if(args[0].equals("-h") && args.length >= 2) {
|
||||
for(Module m : modules)
|
||||
if(args[1].equals(m.name())) {
|
||||
m.printHelp();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
printHelp();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user