/** * */ 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 = "d"; public static final String ARG_DIRECTORY_DEFAULT = ""; 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_INCLUDE_ALL = "a"; public static final String ARG_INCLUDE_ALL_LONG = "all"; public static final String ARG_INCLUDE_ALL_MAN = "Include all branches"; 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 = "Include the HEAD of the master branches"; public static final String ARG_PRODUCTION = "p"; public static final String ARG_PRODUCTION_LONG = "production"; public static final String ARG_PRODUCTION_MAN = "Production mode: the directory does not contain a SAREF extension, but only a file `.saref-repositories.yml`"; public static final String ARG_DEBUG_TEMPLATE = "debug"; public static final String ARG_DEBUG_TEMPLATE_LONG = "debug-template"; public static final String ARG_DEBUG_TEMPLATE_MAN = "Use the debug-template mode of SPARQL-Generate 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_INCLUDE_MASTER, ARG_INCLUDE_MASTER_LONG, false, ARG_INCLUDE_MASTER_MAN) .addOption(ARG_INCLUDE_ALL, ARG_INCLUDE_ALL_LONG, false, ARG_INCLUDE_ALL_MAN) .addOption(ARG_PRODUCTION, ARG_PRODUCTION_LONG, false, ARG_PRODUCTION_MAN) .addOption(ARG_DEBUG_TEMPLATE, ARG_DEBUG_TEMPLATE_LONG, false, ARG_DEBUG_TEMPLATE_MAN); } public static void displayHelp() { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar saref-pipeline.jar", getCMDOptions()); System.exit(-1); } }