This is an automated email from the ASF dual-hosted git repository.

bdelacretaz pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-modelconverter.git


The following commit(s) were added to refs/heads/master by this push:
     new 4da71da  Show usage info on command line error
4da71da is described below

commit 4da71da5a7e61313a0736661437cf8e83bc6cbe5
Author: Bertrand Delacretaz <[email protected]>
AuthorDate: Thu Sep 13 10:09:10 2018 +0200

    Show usage info on command line error
---
 .../java/org/apache/sling/feature/modelconverter/impl/Main.java   | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git 
a/src/main/java/org/apache/sling/feature/modelconverter/impl/Main.java 
b/src/main/java/org/apache/sling/feature/modelconverter/impl/Main.java
index 70be3bb..48d443a 100644
--- a/src/main/java/org/apache/sling/feature/modelconverter/impl/Main.java
+++ b/src/main/java/org/apache/sling/feature/modelconverter/impl/Main.java
@@ -25,6 +25,7 @@ import java.util.List;
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.CommandLineParser;
 import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.HelpFormatter;
 import org.apache.commons.cli.Option;
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.ParseException;
@@ -109,14 +110,21 @@ public class Main {
             }
         } catch ( final ParseException pe) {
             LOGGER.error("Unable to parse command line: {}", pe.getMessage(), 
pe);
+            help(options);
             System.exit(1);
         }
         if ( input == null ) {
             LOGGER.error("Required argument missing: model file or directory");
+            help(options);
             System.exit(1);
         }
     }
 
+    private static void help(Options options) {
+        final HelpFormatter formatter = new HelpFormatter();
+        formatter.printHelp("launcher", options);
+    }
+
     private static ArtifactManager getArtifactManager() {
         final ArtifactManagerConfig amConfig = new ArtifactManagerConfig();
         if ( repoUrls != null ) {

Reply via email to