/*******************************************************************************
 * (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Apache License v2.0 which accompany this distribution.
 *
 * The Apache License is available at
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 *******************************************************************************/
package org.openscore.lang.tools.verifier;

import org.apache.commons.lang.Validate;
import org.openscore.lang.tools.verifier.configuration.VerifierSpringConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.io.File;

/*
 * Created by stoneo on 1/11/2015.
 */
public class VerifierMain {

    public static void main(String[] args) {
        String repositoryPath = args[0];
        Validate.notNull(repositoryPath, "You must pass a path to your repository");
        Validate.isTrue(new File(repositoryPath).isDirectory(), "Directory path argument \'" + repositoryPath + "\' does not lead to a directory");

        ApplicationContext context = new AnnotationConfigApplicationContext(VerifierSpringConfiguration.class);
        SlangContentVerifier slangContentVerifier = context.getBean(SlangContentVerifier.class);
        try {
            int numberOfValidSlangFiles = slangContentVerifier.verifyAllSlangFilesInDirAreValid(repositoryPath);
            System.out.println("SUCCESS: Found " + numberOfValidSlangFiles + " slang files under directory: \"" + repositoryPath + "\" and all are valid.");
            System.exit(0);
        } catch (Exception e) {
            System.out.println(e.getMessage() + "\n\nFAILURE: Validation of slang files under directory: \"" + repositoryPath + "\" failed.");
            // TODO - do we want to throw exception or exit with 1?
            System.exit(1);
        }
    }

}

@@ -522,16 +522,60 @@
 ifier;%0A%0A
+import org.apache.commons.io.FilenameUtils;%0A
 import o
@@ -1089,24 +1089,99 @@
 pository%22);%0A
+        repositoryPath = FilenameUtils.separatorsToSystem(repositoryPath);%0A
         Vali
@@ -1231,16 +1231,32 @@
 ctory(),
+%0A               
  %22Direct

handle file system separators