Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
*
*/
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);
}
}