diff --git a/src/java/org/stathissideris/ascii2image/core/CommandLineConverter.java b/src/java/org/stathissideris/ascii2image/core/CommandLineConverter.java index b2f16c9..937953a 100644 --- a/src/java/org/stathissideris/ascii2image/core/CommandLineConverter.java +++ b/src/java/org/stathissideris/ascii2image/core/CommandLineConverter.java @@ -1,10 +1,10 @@ /** * ditaa - Diagrams Through Ascii Art - * + * * Copyright (C) 2004-2011 Efstathios Sideris * * ditaa is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as + * it under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation, either version 3 of * the License, or (at your option) any later version. * @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with ditaa. If not, see . - * + * */ package org.stathissideris.ascii2image.core; @@ -37,19 +37,19 @@ import org.stathissideris.ascii2image.text.TextGrid; /** - * + * * @author Efstathios Sideris */ public class CommandLineConverter { - + private static String notice = "ditaa version 0.11, Copyright (C) 2004--2017 Efstathios (Stathis) Sideris"; - + private static String[] markupModeAllowedValues = {"use", "ignore", "render"}; - + public static void main(String[] args){ - + long startTime = System.currentTimeMillis(); - + Options cmdLnOptions = new Options(); cmdLnOptions.addOption( OptionBuilder.withLongOpt("help") @@ -65,7 +65,7 @@ public static void main(String[] args){ cmdLnOptions.addOption("E", "no-separation", false, "Prevents the separation of common edges of shapes."); cmdLnOptions.addOption("h", "html", false, "In this case the input is an HTML file. The contents of the
 tags are rendered as diagrams and saved in the images directory and a new HTML file is produced with the appropriate  tags.");
 		cmdLnOptions.addOption("T", "transparent", false, "Causes the diagram to be rendered on a transparent background. Overrides --background.");
-		
+
 		cmdLnOptions.addOption(
 				OptionBuilder.withLongOpt("encoding")
 				.withDescription("The encoding of the input file.")
@@ -89,7 +89,7 @@ public static void main(String[] args){
 				.withArgName("TABS")
 				.create('t')
 				);
-		
+
 		cmdLnOptions.addOption(
 				OptionBuilder.withLongOpt("background")
 				.withDescription("The background colour of the image. The format should be a six-digit hexadecimal number (as in HTML, FF0000 for red). Pass an eight-digit hex to define transparency. This is overridden by --transparent.")
@@ -97,10 +97,10 @@ public static void main(String[] args){
 				.withArgName("BACKGROUND")
 				.create('b')
 				);
-		
+
 		cmdLnOptions.addOption(
 				OptionBuilder.withLongOpt("svg")
-				.withDescription( "Write a SVG image as destination file." )
+				.withDescription( "Write an SVG image as destination file." )
 				.create()
 				);
 
@@ -119,36 +119,36 @@ public static void main(String[] args){
 //				.hasArg()
 //				.withArgName("CONFIG_FILE")
 //				.create('c') );
-		
+
 		CommandLine cmdLine = null;
-		
-		
-		
+
+
+
 		///// parse command line options
 		try {
 			// parse the command line arguments
 			CommandLineParser parser = new PosixParser();
-			
+
 			cmdLine = parser.parse(cmdLnOptions, args);
-						
+
 			// validate that block-size has been set
 			if( cmdLine.hasOption( "block-size" ) ) {
 				// print the value of block-size
 				System.out.println( cmdLine.getOptionValue( "block-size" ) );
 			}
-			
+
 		} catch (org.apache.commons.cli.ParseException e) {
 			System.err.println(e.getMessage());
 			new HelpFormatter().printHelp("java -jar ditaa.jar  [OUTFILE]", cmdLnOptions, true);
 			System.exit(2);
 		}
-		
-		
+
+
 		if(cmdLine.hasOption("help") || args.length == 0 ){
 			new HelpFormatter().printHelp("java -jar ditaa.jar  [OUTFILE]", cmdLnOptions, true);
-			System.exit(0);			
+			System.exit(0);
 		}
-		
+
 		ConversionOptions options = null;
 		try {
 			options = new ConversionOptions(cmdLine);
@@ -160,23 +160,23 @@ public static void main(String[] args){
 			new HelpFormatter().printHelp("java -jar ditaa.jar  [OUTFILE]", cmdLnOptions, true);
 			System.exit(2);
 		}
-		
+
 		args = cmdLine.getArgs();
-		
+
 		if(args.length == 0) {
 			System.err.println("Error: Please provide the input file filename");
 			new HelpFormatter().printHelp("java -jar ditaa.jar  [outfile]", cmdLnOptions, true);
 			System.exit(2);
-		} 
-		
+		}
+
 		if(cmdLine.hasOption("html")){
 			/////// print options before running
 			printRunInfo(cmdLine);
 			String filename = args[0];
-			
+
 			boolean overwrite = false;
 			if(options.processingOptions.overwriteFiles()) overwrite = true;
-			
+
 			String toFilename;
 			if(args.length == 1){
 				toFilename = FileUtils.makeTargetPathname(filename, "html", "_processed", true);
@@ -188,12 +188,12 @@ public static void main(String[] args){
 				System.out.println("Error: File "+toFilename+" exists. If you would like to overwrite it, please use the --overwrite option.");
 				System.exit(0);
 			}
-			
+
 			new HTMLConverter().convertHTMLFile(filename, toFilename, "ditaa_diagram", "images", options);
 			System.exit(0);
-			
+
 		} else { //simple mode
-			
+
 			TextGrid grid = new TextGrid();
 			if(options.processingOptions.getCustomShapes() != null){
 				grid.addToMarkupTags(options.processingOptions.getCustomShapes().keySet());
@@ -208,7 +208,7 @@ public static void main(String[] args){
 
 			boolean overwrite = false;
 			if(options.processingOptions.overwriteFiles()) overwrite = true;
-			
+
 			if(args.length == 1){
 				if (stdIn) { // if using stdin and no output specified, use stdout
 					stdOut = true;
@@ -243,17 +243,17 @@ public static void main(String[] args){
 				System.err.println("Error: Cannot open file "+fromFilename+" for reading");
 				System.exit(1);
 			}
-			
+
 			if(options.processingOptions.printDebugOutput()){
 				if (!stdOut) System.out.println("Using grid:");
 				grid.printDebug();
 			}
-			
+
 			Diagram diagram = new Diagram(grid, options);
 			if (!stdOut) System.out.println("Rendering to file: "+toFilename);
-			
+
 			try {
-			
+
 				if(cmdLine.hasOption("svg")){
 					String content = new SVGRenderer().renderToImage(diagram, options.renderingOptions);
 
@@ -261,7 +261,7 @@ public static void main(String[] args){
 					stream.print(content);
 				} else {
 					RenderedImage image = new BitmapRenderer().renderToImage(diagram, options.renderingOptions);
-			
+
 					OutputStream os = stdOut ? System.out : new FileOutputStream(toFilename);
 					ImageIO.write(image, "png", os);
 				}
@@ -271,25 +271,25 @@ public static void main(String[] args){
 				System.err.println("Error: Cannot write to file "+toFilename);
 				System.exit(1);
 			}
-			
+
 			//BitmapRenderer.renderToPNG(diagram, toFilename, options.renderingOptions);
-			
+
 			long endTime = System.currentTimeMillis();
 			long totalTime  = (endTime - startTime) / 1000;
 			if (!stdOut) System.out.println("Done in "+totalTime+"sec");
-			
+
 //			try {
 //			Thread.sleep(Long.MAX_VALUE);
 //			} catch (InterruptedException e) {
 //			e.printStackTrace();
 //			}
-			
+
 		}
-	}	
+	}
 
 	private static void printRunInfo(CommandLine cmdLine) {
 		System.out.println("\n"+notice+"\n");
-		
+
 		System.out.println("Running with options:");
 		Option[] opts = cmdLine.getOptions();
 		for (Option option : opts) {