Newer
Older
/**
*
*/
package fr.emse.gitlab.saref;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
/**
* @author Omar Qawasmeh
*
*/
public class CMDConfigurations {
public static final String ARG_HELP = "h";
public static final String ARG_HELP_LONG = "help";
public static final String ARG_HELP_MAN = "Show help";
public static final String ARG_INIT = "i";
public static final String ARG_INIT_LONG = "init";
public static final String ARG_INIT_MAN = "Initialize a new SAREF extension development in the current directory";
public static final String ARG_DIRECTORY_LONG = "dir";
public static final String ARG_DIRECTORY_MAN = "Location of the SAREF extension directory (default is .)";
public static final String ARG_REMOTE_ONLY = "r";
public static final String ARG_REMOTE_ONLY_LONG = "remote-only";
public static final String ARG_REMOTE_ONLY_MAN = "Do not check the directory itself. Only consider the repositories listed in the `.saref-repositories.yml` document. Used to generate the website for several extensions.";
public static final String ARG_IGNORE_GIT = "g";
public static final String ARG_IGNORE_GIT_LONG = "no-git";
public static final String ARG_IGNORE_GIT_MAN = "Only check the current state of the repository";
public static final String ARG_IGNORE_EXAMPLES = "e";
public static final String ARG_IGNORE_EXAMPLES_LONG = "ignore-examples";
public static final String ARG_IGNORE_EXAMPLES_MAN = "Only check the SAREF extension ontology. Ignore the examples.";
public static final String ARG_NO_SITE = "s";
public static final String ARG_NO_SITE_LONG = "no-site";
public static final String ARG_NO_SITE_MAN = "Do not generate the static website";
public static final String ARG_IGNORE_TERMS = "t";
public static final String ARG_IGNORE_TERMS_LONG = "no-terms";
public static final String ARG_IGNORE_TERMS_MAN = "Do not generate the website for terms";
public static final String ARG_INCLUDE_MASTER = "m";
public static final String ARG_INCLUDE_MASTER_LONG = "master";
public static final String ARG_INCLUDE_MASTER_MAN = "Check the master branches of the remote repositories listed in the `.saref-repositories.yml` document";
public static final String ARG_RELEASE = "x";
public static final String ARG_RELEASE_LONG = "release";
public static final String ARG_RELEASE_MAN = "Run in strict mode, only when on a branch `prerelease-vx.y.z` or `release-vx.y.z`";
public static final String ARG_VERBOSE = "v";
public static final String ARG_VERBOSE_LONG = "verbose";
public static final String ARG_VERBOSE_MAN = "Use verbose mode. (For example, use SPARQL-Generate in --debug-template mode when generating the documentation)";
public static CommandLine parseArguments(String[] args) throws ParseException {
DefaultParser commandLineParser = new DefaultParser();
CommandLine cl = commandLineParser.parse(getCMDOptions(), args);
return cl;
}
public static Options getCMDOptions() {
return new Options().addOption(ARG_HELP, ARG_HELP_LONG, false, ARG_HELP_MAN)
// .addOption(ARG_INIT, ARG_INIT_LONG, true, ARG_INIT_MAN)
.addOption(ARG_DIRECTORY, ARG_DIRECTORY_LONG, true, ARG_DIRECTORY_MAN)
.addOption(ARG_REMOTE_ONLY, ARG_REMOTE_ONLY_LONG, false, ARG_REMOTE_ONLY_MAN)
.addOption(ARG_IGNORE_EXAMPLES, ARG_IGNORE_EXAMPLES_LONG, false, ARG_IGNORE_EXAMPLES_MAN)
.addOption(ARG_IGNORE_TERMS, ARG_IGNORE_TERMS_LONG, false, ARG_IGNORE_TERMS_MAN)
.addOption(ARG_IGNORE_GIT, ARG_IGNORE_GIT_LONG, false, ARG_IGNORE_GIT_MAN)
.addOption(ARG_NO_SITE, ARG_NO_SITE_LONG, false, ARG_NO_SITE_MAN)
.addOption(ARG_INCLUDE_MASTER, ARG_INCLUDE_MASTER_LONG, false, ARG_INCLUDE_MASTER_MAN)
.addOption(ARG_RELEASE, ARG_RELEASE_LONG, false, ARG_RELEASE_MAN)
.addOption(ARG_VERBOSE, ARG_VERBOSE_LONG, false, ARG_VERBOSE_MAN);