Commits

Stephen McKamey committed addd9b2

improving CLI

Comments (0)

Files changed (8)

duel-compiler/pom.xml

 
 	<groupId>org.duelengine</groupId>
 	<artifactId>duel-compiler</artifactId>
-	<version>0.8.0</version>
+	<version>0.8.1</version>
 	<packaging>jar</packaging>
 
 	<name>DUEL Compiler</name>
 				<configuration>
 					<archive>
 						<manifest>
+							<addClasspath>true</addClasspath>
 							<mainClass>org.duelengine.duel.compiler.CLI</mainClass>
 						</manifest>
 					</archive>

duel-compiler/src/main/java/org/duelengine/duel/compiler/CLI.java

 
 public class CLI {
 
-	private static final String HELP =
-		"Usage:\n" +
-		"\tjava -jar duel-compiler.jar <input-file|input-folder>\n" +
-		"\tjava -jar duel-compiler.jar <input-file|input-folder> <output-folder>\n" +
-		"\tjava -jar duel-compiler.jar <input-file|input-folder> <output-client-folder> <output-server-folder>\n\n"+
-		"\tinput-file: path to the DUEL input file (e.g. foo.duel)\n"+
-		"\tinput-folder: path to the input folder containing DUEL files\n"+
-		"\toutput-folder: path to the output folder\n"+
-		"\toutput-client-folder: path to the view scripts folder\n"+
-		"\toutput-server-folder: path to the source code folder\n";
+	private static final String SEPARATOR = "========================================";
+	private static final String HELP = "java -jar duel-compiler.jar\n"+
+			"  --help                       : this help text\n"+
+			"  -in <source-file|source-dir> : file path to the source file or folder (required)\n"+
+			"  -client-out <target-dir>     : file path to the target output directory (default: <source-dir>)\n"+
+			"  -server-out <target-dir>     : file path to the target output directory (default: <source-dir>)\n"+
+			"  -client-prefix <package>     : client-side package name\n"+
+			"  -server-prefix <package>     : server-side package name\n";
 
 	public static void main(String[] args) {
 		if (args.length < 1) {
 		}
 
 		DuelCompiler compiler = new DuelCompiler();
-		compiler.setInputDir(args[0]);
+		System.out.println(SEPARATOR);
+		System.out.println("DUEL compiler");
+		for (int i=0; i<args.length; i++) {
+			String arg = args[i];
 
-		if (args.length > 1) {
-			compiler.setOutputClientDir(args[1]);
+			if ("-in".equals(arg)) {
+				compiler.setInputDir(args[++i]);
 
-			if (args.length > 2) {
-				compiler.setOutputServerDir(args[2]);
+			} else if ("-client-out".equals(arg)) {
+				compiler.setOutputClientDir(args[++i]);
+
+			} else if ("-server-out".equals(arg)) {
+				compiler.setOutputServerDir(args[++i]);
+
+			} else if ("-client-prefix".equals(arg)) {
+				compiler.setClientPrefix(args[++i]);
+
+			} else if ("-server-prefix".equals(arg)) {
+				compiler.setServerPrefix(args[++i]);
+
+			} else if ("--help".equalsIgnoreCase(arg)) {
+				System.out.println(HELP);
+				System.out.println(SEPARATOR);
+				return;
+
+			} else {
+				System.out.println(HELP);
+				System.out.println(SEPARATOR);
+				return;
 			}
 		}
 
 		try {
 			compiler.execute();
 
-		} catch (IOException e) {
-			e.printStackTrace();
+		} catch (Exception ex) {
+			ex.printStackTrace(System.err);
 		}
+		System.out.println(SEPARATOR);
 	}
-
 }

duel-compiler/src/main/java/org/duelengine/duel/compiler/DuelCompiler.java

 		}
 
 		if (this.outputClientDir == null) {
-			this.outputClientDir = this.inputDir.getParentFile();
+			this.outputClientDir = this.inputDir.isDirectory() ? this.inputDir :  this.inputDir.getParentFile();
 		}
 
 		if (this.outputServerDir == null) {
-			this.outputServerDir = this.inputDir.getParentFile();
+			this.outputServerDir = this.inputDir.isDirectory() ? this.inputDir :  this.inputDir.getParentFile();
 		}
 
 		return true;
 
 	<groupId>org.duelengine</groupId>
 	<artifactId>duel-js</artifactId>
-	<version>0.8.0</version>
+	<version>0.8.1</version>
 	<packaging>pom</packaging>
 
 	<name>DUEL Client Scripts</name>

duel-js/target/duel.js

 /*global window */
 
 /**
- * @license DUEL v0.8.0 http://duelengine.org
+ * @license DUEL v0.8.1 http://duelengine.org
  * Copyright (c)2006-2012 Stephen M. McKamey.
  * Licensed under The MIT License.
  */

duel-js/target/duel.min.js

 /*
- DUEL v0.8.0 http://duelengine.org
+ DUEL v0.8.1 http://duelengine.org
  Copyright (c)2006-2012 Stephen M. McKamey.
  Licensed under The MIT License.
 */

duel-maven-plugin/pom.xml

 
 	<groupId>org.duelengine</groupId>
 	<artifactId>duel-maven-plugin</artifactId>
-	<version>0.8.0</version>
+	<version>0.8.1</version>
 	<packaging>maven-plugin</packaging>
 
 	<name>DUEL Maven Plugin</name>

duel-runtime/pom.xml

 
 	<groupId>org.duelengine</groupId>
 	<artifactId>duel-runtime</artifactId>
-	<version>0.8.0</version>
+	<version>0.8.1</version>
 	<packaging>jar</packaging>
 
 	<name>DUEL Runtime</name>