5eab866e83d9bf135810a3ccce916d3429c8d0c4
[yangtools.git] / yang-validation-tool / src / main / java / org / opendaylight / yangtools / yang / validation / tool / Main.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.validation.tool;
9
10 import java.io.File;
11 import java.net.URISyntaxException;
12 import java.util.Arrays;
13 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
16
17 public final class Main {
18     private static final Logger LOG = LoggerFactory.getLogger(Main.class);
19
20     private Main() {
21
22     }
23
24     public static void main(final String[] args) throws URISyntaxException {
25         final Params params = ParamsUtil.parseArgs(args, Params.getParser());
26
27         if (params.isValid()) {
28             final File[] yangModels = params.getYangSourceDir().listFiles();
29
30             try {
31                 YangParserTestUtils.parseYangSources(Arrays.asList(yangModels));
32             } catch (Exception e) {
33                 LOG.error("Yang files could not be parsed.", e);
34             }
35         }
36     }
37 }