2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.validation.tool;
11 import net.sourceforge.argparse4j.ArgumentParsers;
12 import net.sourceforge.argparse4j.annotation.Arg;
13 import net.sourceforge.argparse4j.inf.ArgumentParser;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
18 private static final Logger LOG = LoggerFactory.getLogger(Params.class);
20 @Arg(dest = "yang-source-dir")
21 private File yangSourceDir;
23 static ArgumentParser getParser() {
24 final ArgumentParser parser = ArgumentParsers.newFor("jar_file_name").addHelp(true).build();
25 parser.description("Validation Tool for Yang Models")
28 parser.addArgumentGroup("Required arguments")
29 .addArgument("--yang-source-dir")
32 .help("directory containing yang models which will be parsed")
33 .dest("yang-source-dir")
39 public boolean isValid() {
40 if (yangSourceDir == null) {
43 if (!yangSourceDir.exists()) {
44 LOG.error("Yang source directory has to exist");
47 if (!yangSourceDir.canRead()) {
48 LOG.error("Yang source directory has to be readable");
51 final String[] listed = yangSourceDir.list();
53 LOG.error("Yang source directory {} is not a directory or cannot be read", yangSourceDir.getPath());
56 if (listed.length == 0) {
57 LOG.error("Yang source directory {} doesn't contain any model", yangSourceDir.getPath());
64 public File getYangSourceDir() {