incubator-odf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject [odftoolkit] 01/02: validator: return a status code indicating success or failure
Date Fri, 22 Jun 2018 15:38:30 GMT
This is an automated email from the ASF dual-hosted git repository.

mst pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/odftoolkit.git

commit b14e2f6c63c18894286c99ee8dde9070e24b41c2
Author: Michael Stahl <Michael.Stahl@cib.de>
AuthorDate: Fri Jun 22 17:10:22 2018 +0200

    validator: return a status code indicating success or failure
    
    It is a useful convention to return a failing status code in case
    something went horribly wrong during execution, or the command line
    arguments are invalid.  This can then be checked e.g. in LO's
    test::BootstrapFixture.
    
    (If validation errors are found, it was still a successful execution.)
---
 .../src/main/java/org/odftoolkit/odfvalidator/Main.java    | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/validator/src/main/java/org/odftoolkit/odfvalidator/Main.java b/validator/src/main/java/org/odftoolkit/odfvalidator/Main.java
index 1801b4c..bffeb1e 100644
--- a/validator/src/main/java/org/odftoolkit/odfvalidator/Main.java
+++ b/validator/src/main/java/org/odftoolkit/odfvalidator/Main.java
@@ -177,7 +177,7 @@ public class Main {
             {
                 System.out.print(aArg);
                 System.out.println(": unknown option, use '-h' for help");
-                return;
+                System.exit(1);
             }
             else if( aArg.length()>0 )
             {
@@ -207,13 +207,13 @@ public class Main {
         if( !bCommandLineValid || bPrintHelp )
         {
             printUsage();
-            return;
+            System.exit(bCommandLineValid ? 0 : 1);
         }
         if( bPrintVersion )
         {
             System.out.print("odfvalidator v");
             System.out.println( VERSION );
-            return;
+            System.exit(0);
         }
 
         try
@@ -225,7 +225,7 @@ public class Main {
                 Iterator<String> aIter = aFileNames.iterator();
                 while( aIter.hasNext() )
                     aMetaInformation.getInformation(aIter.next());
-                return;
+                System.exit(0);
             }
 
             // Read configuration - by default aConfig is null, so the version
@@ -244,13 +244,13 @@ public class Main {
                     if( aConfigFileName != null )
                     {
                         System.out.println( aConfigFile.getAbsolutePath() + ": file not found.");
-                        return;
+                        System.exit(1);
                     }
                 }
                 catch( IOException e )
                 {
                     System.out.println("error reading " + aConfigFile.getAbsolutePath() +
": " + e.getLocalizedMessage() );
-                    return;
+                    System.exit(1);
                 }
 
                 // Permit input file override from command line, even
@@ -305,11 +305,13 @@ public class Main {
         {
             System.out.println( e.getMessage() );
             System.out.println( "Validation aborted." );
+            System.exit(1);
         }
         catch( FileNotFoundException e )
         {
             System.out.println( e.getMessage() );
             System.out.println( "Validation aborted." );
+            System.exit(1);
         }
     }
 


Mime
View raw message