/** * */ 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 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); } public static void displayHelp() { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar saref-pipeline.jar", getCMDOptions()); System.exit(-1); } }