From 8ceb09beed839cc3b2a15fafbbb7f4a238942e85 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Wed, 20 Sep 2017 10:44:11 +0200 Subject: [PATCH] Minor fixes in Main rgd. CLI processing --- .../src/com/minres/rdl/generator/Main.xtend | 18 +++--- .../com/minres/rdl/generator/Main.java | 56 +++++++++---------- 2 files changed, 34 insertions(+), 40 deletions(-) diff --git a/com.minres.rdl.parent/com.minres.rdl/src/com/minres/rdl/generator/Main.xtend b/com.minres.rdl.parent/com.minres.rdl/src/com/minres/rdl/generator/Main.xtend index cc854c2..28ecfdc 100644 --- a/com.minres.rdl.parent/com.minres.rdl/src/com/minres/rdl/generator/Main.xtend +++ b/com.minres.rdl.parent/com.minres.rdl/src/com/minres/rdl/generator/Main.xtend @@ -4,7 +4,6 @@ import com.google.inject.Inject import com.google.inject.Provider import com.minres.rdl.RDLStandaloneSetup import java.lang.reflect.MalformedParametersException -import java.util.ArrayList import org.eclipse.emf.common.util.URI import org.eclipse.emf.ecore.resource.ResourceSet import org.eclipse.emf.mwe.utils.ProjectMapping @@ -23,7 +22,7 @@ import com.minres.rdl.generator.Options.Separator class Main { - private static String USAGE_STR = "RDL2code [-h] [-v] [-o=] [-d=] [-p=] "; + private val USAGE_STR = "RDL2code [-h] [-v] [-I ] [-s ] [-g ] "; def static main(String[] args) { if (args.empty) { @@ -31,7 +30,7 @@ class Main { return } val injector = new RDLStandaloneSetup().createInjectorAndDoEMFRegistration - val Main main = injector.getInstance(Main) + val main = injector.getInstance(Main) try { main.run(args) } catch (MalformedParametersException e) { @@ -60,14 +59,13 @@ class Main { val opt = new Options(args, 0, Integer.MAX_VALUE); opt.getSet().addOption("h", Multiplicity.ZERO_OR_ONE); opt.getSet().addOption("v", Multiplicity.ZERO_OR_ONE); - opt.getSet().addOption("i", Separator.EQUALS, Multiplicity.ZERO_OR_ONE); - opt.getSet().addOption("s", Separator.EQUALS, Multiplicity.ZERO_OR_ONE); - opt.getSet().addOption("g", Separator.EQUALS, Multiplicity.ZERO_OR_ONE); - opt.getSet().addOption("I", Separator.EQUALS, Multiplicity.ZERO_OR_ONE); + opt.getSet().addOption("i", Separator.BLANK, Multiplicity.ZERO_OR_ONE); + opt.getSet().addOption("s", Separator.BLANK, Multiplicity.ZERO_OR_ONE); + opt.getSet().addOption("g", Separator.BLANK, Multiplicity.ZERO_OR_ONE); + opt.getSet().addOption("I", Separator.BLANK, Multiplicity.ZERO_OR_ONE); if (!opt.check(false, false)) { // Print usage hints - System.err.println("Error processing command line: " + opt.getCheckErrors()); System.err.println("Usage is: " + USAGE_STR); - throw new MalformedParametersException("Error processing command line: " + opt.getCheckErrors()); + throw new MalformedParametersException(opt.getCheckErrors()); } // Normal processing if (opt.getSet().isSet("h")) { @@ -84,7 +82,7 @@ class Main { } // Configure and start the generator fileAccess.outputPath = 'src-gen/' - #{'incl-out' -> false, 'src-out' -> false, 'gen-out'->true}.forEach[p1, p2| + #{'incl-out' -> false, 'src-out' -> false, 'gen-out' -> true}.forEach[p1, p2| if(opt.getSet().isSet(p1.substring(0, 1))) fileAccess.setOutputPath(p1, opt.getSet().getOption(p1.substring(0, 1)).getResultValue(0)+'/') else diff --git a/com.minres.rdl.parent/com.minres.rdl/xtend-gen/com/minres/rdl/generator/Main.java b/com.minres.rdl.parent/com.minres.rdl/xtend-gen/com/minres/rdl/generator/Main.java index 1b518ac..48441a3 100644 --- a/com.minres.rdl.parent/com.minres.rdl/xtend-gen/com/minres/rdl/generator/Main.java +++ b/com.minres.rdl.parent/com.minres.rdl/xtend-gen/com/minres/rdl/generator/Main.java @@ -36,7 +36,7 @@ import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; @SuppressWarnings("all") public class Main { - private static String USAGE_STR = "RDL2code [-h] [-v] [-o=] [-d=] [-p=] "; + private final String USAGE_STR = "RDL2code [-h] [-v] [-I ] [-s ] [-g ] "; public static void main(final String[] args) { boolean _isEmpty = ((List)Conversions.doWrapArray(args)).isEmpty(); @@ -94,24 +94,20 @@ public class Main { final Options opt = new Options(args, 0, Integer.MAX_VALUE); opt.getSet().addOption("h", Options.Multiplicity.ZERO_OR_ONE); opt.getSet().addOption("v", Options.Multiplicity.ZERO_OR_ONE); - opt.getSet().addOption("i", Options.Separator.EQUALS, Options.Multiplicity.ZERO_OR_ONE); - opt.getSet().addOption("s", Options.Separator.EQUALS, Options.Multiplicity.ZERO_OR_ONE); - opt.getSet().addOption("g", Options.Separator.EQUALS, Options.Multiplicity.ZERO_OR_ONE); - opt.getSet().addOption("I", Options.Separator.EQUALS, Options.Multiplicity.ZERO_OR_ONE); + opt.getSet().addOption("i", Options.Separator.BLANK, Options.Multiplicity.ZERO_OR_ONE); + opt.getSet().addOption("s", Options.Separator.BLANK, Options.Multiplicity.ZERO_OR_ONE); + opt.getSet().addOption("g", Options.Separator.BLANK, Options.Multiplicity.ZERO_OR_ONE); + opt.getSet().addOption("I", Options.Separator.BLANK, Options.Multiplicity.ZERO_OR_ONE); boolean _check = opt.check(false, false); boolean _not = (!_check); if (_not) { + System.err.println(("Usage is: " + this.USAGE_STR)); String _checkErrors = opt.getCheckErrors(); - String _plus = ("Error processing command line: " + _checkErrors); - System.err.println(_plus); - System.err.println(("Usage is: " + Main.USAGE_STR)); - String _checkErrors_1 = opt.getCheckErrors(); - String _plus_1 = ("Error processing command line: " + _checkErrors_1); - throw new MalformedParametersException(_plus_1); + throw new MalformedParametersException(_checkErrors); } boolean _isSet = opt.getSet().isSet("h"); if (_isSet) { - InputOutput.println(("Usage: " + Main.USAGE_STR)); + InputOutput.println(("Usage: " + this.USAGE_STR)); return; } boolean _xifexpression = false; @@ -137,8 +133,8 @@ public class Main { boolean _isSet_3 = opt.getSet().isSet(p1.substring(0, 1)); if (_isSet_3) { String _resultValue = opt.getSet().getOption(p1.substring(0, 1)).getResultValue(0); - String _plus_2 = (_resultValue + "/"); - this.fileAccess.setOutputPath(p1, _plus_2); + String _plus = (_resultValue + "/"); + this.fileAccess.setOutputPath(p1, _plus); } else { this.fileAccess.setOutputPath(p1, "src-gen/"); } @@ -162,16 +158,16 @@ public class Main { boolean _not_1 = (!_isEmpty); if (_not_1) { URI _uRI = resource.getURI(); - String _plus_2 = ("Error validating " + _uRI); - System.err.println(_plus_2); + String _plus = ("Error validating " + _uRI); + System.err.println(_plus); final Consumer _function_2 = (Issue it) -> { System.err.println(it); }; issues.forEach(_function_2); URI _uRI_1 = resource.getURI(); - String _plus_3 = ("error validating " + _uRI_1); + String _plus_1 = ("error validating " + _uRI_1); int _size = issues.size(); - throw new ParseException(_plus_3, _size); + throw new ParseException(_plus_1, _size); } GeneratorContext _generatorContext = new GeneratorContext(); final Procedure1 _function_3 = (GeneratorContext it) -> { @@ -185,17 +181,17 @@ public class Main { try { if (verbose) { URI _uRI_2 = this.fileAccess.getURI("", "incl-out"); - String _plus_4 = ("includes are in " + _uRI_2); - String _plus_5 = (_plus_4 + ", "); - InputOutput.print(_plus_5); + String _plus_2 = ("includes are in " + _uRI_2); + String _plus_3 = (_plus_2 + ", "); + InputOutput.print(_plus_3); } } catch (final Throwable _t) { if (_t instanceof Exception) { final Exception e = (Exception)_t; URI _uRI_3 = this.fileAccess.getURI(""); - String _plus_6 = ("includes are in " + _uRI_3); - String _plus_7 = (_plus_6 + ", "); - InputOutput.print(_plus_7); + String _plus_4 = ("includes are in " + _uRI_3); + String _plus_5 = (_plus_4 + ", "); + InputOutput.print(_plus_5); } else { throw Exceptions.sneakyThrow(_t); } @@ -203,17 +199,17 @@ public class Main { try { if (verbose) { URI _uRI_4 = this.fileAccess.getURI("", "src-out"); - String _plus_8 = ("sources are in " + _uRI_4); - String _plus_9 = (_plus_8 + ", "); - InputOutput.println(_plus_9); + String _plus_6 = ("sources are in " + _uRI_4); + String _plus_7 = (_plus_6 + ", "); + InputOutput.println(_plus_7); } } catch (final Throwable _t_1) { if (_t_1 instanceof Exception) { final Exception e_1 = (Exception)_t_1; URI _uRI_5 = this.fileAccess.getURI(""); - String _plus_10 = ("sources are in " + _uRI_5); - String _plus_11 = (_plus_10 + ", "); - InputOutput.println(_plus_11); + String _plus_8 = ("sources are in " + _uRI_5); + String _plus_9 = (_plus_8 + ", "); + InputOutput.println(_plus_9); } else { throw Exceptions.sneakyThrow(_t_1); }