Revision: 5568
          http://sourceforge.net/p/jump-pilot/code/5568
Author:   edso
Date:     2017-11-18 04:12:15 +0000 (Sat, 18 Nov 2017)
Log Message:
-----------
always print help output when a wrong parameter/option was given
added --help switch as users might expect it

Modified Paths:
--------------
    core/trunk/ChangeLog
    core/trunk/src/com/vividsolutions/jump/util/commandline/CommandLine.java
    core/trunk/src/com/vividsolutions/jump/workbench/JUMPWorkbench.java

Modified: core/trunk/ChangeLog
===================================================================
--- core/trunk/ChangeLog        2017-11-18 03:55:28 UTC (rev 5567)
+++ core/trunk/ChangeLog        2017-11-18 04:12:15 UTC (rev 5568)
@@ -3,6 +3,10 @@
 # 2. make sure that lines break at 80 chars for constricted display situations
 #<-------------------------------- 80 chars 
---------------------------------->#
 
+2017-11-18 ede
+  * always print help output when a wrong parameter/option was given
+  * added --help switch as users might expect it
+
 2017-11-17 Matthias Scholz <m...@jammerhund.de>
   * added methods for handling multiple ApplicationExitHandler in the
     WorkbenchFrame. Set the old getApplicationExitHandler() and

Modified: 
core/trunk/src/com/vividsolutions/jump/util/commandline/CommandLine.java
===================================================================
--- core/trunk/src/com/vividsolutions/jump/util/commandline/CommandLine.java    
2017-11-18 03:55:28 UTC (rev 5567)
+++ core/trunk/src/com/vividsolutions/jump/util/commandline/CommandLine.java    
2017-11-18 04:12:15 UTC (rev 5568)
@@ -93,9 +93,18 @@
   }
 
   public String printDoc() {
+    return printDoc(null);
+  }
+  
+  public String printDoc(Exception e) {
 
-    String out = "Syntax:\n  oj_starter [-option [<parameter>]]... 
[<project_file>]... [<data_file>]...\n\nOptions:\n";
+    String out = "";
+        
+    if (e instanceof Exception )
+      out += "Error:\n  " + e.getMessage() + "\n\n";
 
+    out += "Syntax:\n  oj_starter [-option [<parameter>]]... 
[<project_file>]... [<data_file>]...\n\nOptions:\n";
+
     for (OptionSpec optionSpec : optSpecs) {
       String names = "";
       for (String name : optionSpec.getNames()) {

Modified: core/trunk/src/com/vividsolutions/jump/workbench/JUMPWorkbench.java
===================================================================
--- core/trunk/src/com/vividsolutions/jump/workbench/JUMPWorkbench.java 
2017-11-18 03:55:28 UTC (rev 5567)
+++ core/trunk/src/com/vividsolutions/jump/workbench/JUMPWorkbench.java 
2017-11-18 04:12:15 UTC (rev 5568)
@@ -679,7 +679,12 @@
     commandLine.addOptionSpec(new OptionSpec(new String[] { "p",
         "print-properties" }, 0, "print a list of runtime properties"));
 
-    commandLine.parse(args);
+    try {
+      commandLine.parse(args);
+    } catch (ParseException e) {
+      printProperly(commandLine.printDoc(e));
+      System.exit(1);
+    }
   }
 
   public PlugInManager getPlugInManager() {


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to