public class NativeMain extends AbstractLauncher implements ILaunchOptions{
- private static final String OPTION_PROJECTPATH = "projectpath";
- private static final String OPTION_PROJECTNAME = "projectname";
- private static final String OPTION_SAMPLEPATH = "samplepath";
+ private static final String OPTION_PROJECTPATH = "path";
+ private static final String OPTION_PROJECTNAME = "name";
+ private static final String OPTION_SAMPLE = "sample";
- private static final String DESC_SAMPLEPATH = "sample or template path. (Default: empty project template path) ";
- private static final String DESC_PROJECTPATH = "path of project to be created. (Default: {current directory}/{sample name})";
- private static final String DESC_PROJECTNAME = "name of project to be created. (Default: last folder name of the project path)";
+ private static final String DESC_PROJECTPATH = "Path of the project to be created. (Default: {current directory}/{project name})";
+ private static final String DESC_PROJECTNAME = "Name of the project to be created. (Default: sample type)";
+ private static final String DESC_SAMPLE = "Type of the sample. (Default: empty)\n\t\t\tempty: empty application\n\t\t\tform: form based application\n\t\t\tshared: shared library\n\t\t\tstatic: static library\n\t\t\tservice: service application\n\t\t\ttab: tab based application";
- private static final String LOCATION_CPP_EMPTYPROJECT="native/cpp/Template/Tizen Native/Empty Application/empty";
+ private static final String SAMPLE_EMPTYPROJECT = "native/cpp/Template/Tizen Native/Empty Application/empty";
+ private static final String SAMPLE_FORM = "native/cpp/Template/Tizen Native/Form-based Application/formapp";
+ private static final String SAMPLE_SHARED = "native/cpp/Template/Tizen Native/Library/sharedlibrary";
+ private static final String SAMPLE_STATIC = "native/cpp/Template/Tizen Native/Library/staticlibrary";
+ private static final String SAMPLE_SERVICE = "native/cpp/Template/Tizen Native/Service Application/serviceapp";
+ private static final String SAMPLE_TAB = "native/cpp/Template/Tizen Native/Tab-based Application/tabapp";
/**
* Entry point for cli main
final Prompter prompter = getPrompter();
logger.trace("get user input");
- String sampleDir = cmdLine.getOptionValue(OPTION_SAMPLEPATH);
- if(StringUtil.isEmpty(sampleDir)) {
- String samplePath = InstallPathConfig.getSamplesPath();
- sampleDir = FileUtil.appendPath(samplePath, LOCATION_CPP_EMPTYPROJECT);
+ String sampleName = cmdLine.getOptionValue(OPTION_SAMPLE);
+ String sampleDir = "";
+ String samplePath = InstallPathConfig.getSamplesPath();
+ if(StringUtil.isEmpty(sampleName) || sampleName.equals("empty")) {
+ sampleName = "empty";
+ sampleDir = FileUtil.appendPath(samplePath, SAMPLE_EMPTYPROJECT);
}
- String targetDir = cmdLine.getOptionValue(OPTION_PROJECTPATH);
-
- if(StringUtil.isEmpty(targetDir)) {
- File sampleFile = new File(sampleDir);
- File currentFile = new File("");
- targetDir = FileUtil.appendPath(currentFile.getAbsolutePath(), sampleFile.getName());
+ else if(sampleName.equals("form")) {
+ sampleDir = FileUtil.appendPath(samplePath, SAMPLE_FORM);
+ }
+ else if(sampleName.equals("service")) {
+ sampleDir = FileUtil.appendPath(samplePath, SAMPLE_SERVICE);
+ }
+ else if(sampleName.equals("shared")) {
+ sampleDir = FileUtil.appendPath(samplePath, SAMPLE_SHARED);
+ }
+ else if(sampleName.equals("static")) {
+ sampleDir = FileUtil.appendPath(samplePath, SAMPLE_STATIC);
+ }
+ else if(sampleName.equals("tab"))
+ {
+ sampleDir = FileUtil.appendPath(samplePath, SAMPLE_TAB);
+ }
+ else {
+ logger.error("Sample " + sampleDir + " is not supported. Empty project is being created");
+ sampleName = "empty";
+ sampleDir = FileUtil.appendPath(samplePath, SAMPLE_EMPTYPROJECT);
}
String projectName = cmdLine.getOptionValue(OPTION_PROJECTNAME);
-
if(StringUtil.isEmpty(projectName)) {
- File projectFile = new File(targetDir);
- projectName = projectFile.getName();
+ projectName = sampleName;
}
+
+ String targetDir = cmdLine.getOptionValue(OPTION_PROJECTPATH);
+ if(StringUtil.isEmpty(targetDir)) {
+ File currentFile = new File("");
+ targetDir = FileUtil.appendPath(currentFile.getAbsolutePath(), projectName);
+ }
+
if(new File(targetDir).exists()) {
ChoiceOption yes = new ChoiceOption( "Yes" );
ChoiceOption no = new ChoiceOption( "No", true );
}
}
- logger.trace("execute native project gen");
+ System.out.println("Create " + projectName + " project");
TizenTemplate template = new TizenTemplate(new File(sampleDir).getAbsolutePath(), projectName, new File(targetDir).getAbsolutePath());
TizenTemplateEngine.createProject(template, WizardMode.CLI);
+ System.out.println("Project created succcessfully in " + template.getProjectPath() + "\nTo build the project, run native-make in " + template.getProjectPath() + File.separatorChar + "CommandLineBuild");
+ }
+
+ @Override
+ protected String printHelp() {
+ StringBuffer helpBuffer = new StringBuffer();
+ helpBuffer.append("usage: native-gen [OPTION]\nCreate project\n\n");
+ helpBuffer.append(getHelp().getHelp());
+ String helpStr = helpBuffer.toString();
+ getPrompter().error(helpStr);
+ return helpStr;
}
@SuppressWarnings("static-access")
@Override
protected Options getOptions() {
Options result = super.getOptions();
-
- result.addOption(OptionBuilder.hasArg().withLongOpt(OPTION_SAMPLEPATH).withDescription(DESC_SAMPLEPATH).create("s"));
+ result.addOption(OptionBuilder.hasArg().withLongOpt(OPTION_SAMPLE).withDescription(DESC_SAMPLE).create("s"));
result.addOption(OptionBuilder.hasArg().withLongOpt(OPTION_PROJECTPATH).withDescription(DESC_PROJECTPATH).create("p"));
result.addOption(OptionBuilder.hasArg().withLongOpt(OPTION_PROJECTNAME).withDescription(DESC_PROJECTNAME).create("n"));
-
return result;
}
-}
+}
\ No newline at end of file