import java.util.ArrayList;
import java.util.List;
-import org.tizen.nativecommon.build.SmartBuildInterface;
import org.tizen.nativecommon.build.exception.SBIException;
import org.tizen.ncli.ide.subcommands.CreateProjectCommandData;
public static String commands = "build-native build-web cli-config create debug help install list package run sign uninstall";
- public static String[][] subCommands = { { "list", "device" },
- { "create", "project security-profile security-profile-item certificate" }, { "help", commands } };
-
- public static String[][] options = { { "cli-config", "--list --global" },
- { "build-native", "--predefine-option --platform --toolchain --build-target --build-configuration" },
- { "build-web", "--output -opt --optimize -euf --exclude-uifw -efum --exclude-uifw-min" }, { "sign", "--profile" },
- { "package", "-t --type --sign -ref --ref-project" }, { "install", "--target" }, { "uninstall", "--target" },
- { "run", "--target" }, { "debug", "--target" } };
+ public static String[][] subCommands = {
+ { "list", "device" },
+ { "create", "project security-profile security-profile-item certificate" },
+ { "help", commands } };
+
+ public static String[][] options = {
+ { "cli-config", "--list --global" },
+ { "build-native", "--predefine-option --arch --compiler --configuration" },
+ { "build-web", "--output -opt --optimize -euf --exclude-uifw -efum --exclude-uifw-min" },
+ { "sign", "--profile" },
+ { "package", "-t --type --sign -ref --ref-project" },
+ { "install", "--target" },
+ { "uninstall", "--target" },
+ { "run", "--target" },
+ { "debug", "--target" }
+ };
public static String[][] optionsForSub = {
{ "project", "-t --type -n --name -out --output" },
public static String[] mainCommandsHaveDuplicatedOptions = { "create", "build-web", "package" };
- public static String[][] duplicatedOptions = { { "-opt", "--optimize" }, { "-euf", "--exclude-uifw" },
- { "-eufm", "--exclude-uifw-min" }, { "-e", "--exclude" }, { "-t", "--type" }, { "-n", "--name" },
- { "-ref", "--ref-project" }
-
- };
-
- public enum casesForInputSuggestion {
- platform("--platform"), toolchain("--toolchain"), buildtarget("--build-target"), name("-n");
-
+ public static String[][] duplicatedOptions = {
+ { "-opt", "--optimize" },
+ { "-euf", "--exclude-uifw" },
+ { "-eufm", "--exclude-uifw-min" },
+ { "-e", "--exclude" },
+ { "-t", "--type" },
+ { "-n", "--name" },
+ { "-ref", "--ref-project" }
+ };
+
+ public enum optionSuggestion {
+ architecture(options[1][0], "--arch", "x86 arm"),
+ compiler(options[1][0], "--compiler", "llvm gcc"),
+ configuration(options[1][0], "--configuration", "Debug Release Dynamic Analyzer"),
+ name("-n");
+
+ private String mainCmd;
private String option;
+ private String suggestion;
+
+ private optionSuggestion(String option) {
+ this.option = option;
+ }
- private casesForInputSuggestion(String option) {
+ private optionSuggestion(String mainCmd, String option, String suggestion) {
+ this.mainCmd = mainCmd;
this.option = option;
+ this.suggestion = suggestion;
+ }
+
+ public String getSuggestion() {
+ return suggestion;
}
public String getOption() {
String[] inputs = args;
int count = inputs.length;
- boolean needSuggestion = false;
- casesForInputSuggestion input = null;
- for (casesForInputSuggestion optionFortSuggestion : casesForInputSuggestion.values()) {
- if (optionFortSuggestion.getOption().equals(inputs[count - 1])) {
- needSuggestion = true;
- input = optionFortSuggestion;
- break;
+ if (count > 2) {
+ boolean needSuggestion = false;
+ optionSuggestion input = null;
+ for (optionSuggestion optionFortSuggestion : optionSuggestion.values()) {
+ if (optionFortSuggestion.getOption().equals(inputs[count - 1])) {
+ needSuggestion = true;
+ input = optionFortSuggestion;
+ break;
+ }
+ }
+ if (needSuggestion) {
+ try {
+ System.out.println(makeInputSuggestion(input));
+ } catch (SBIException e) {
+ System.out.println("Faile to get suggestion for " + input.getOption());
+ }
+ return;
}
}
- if (needSuggestion) {
- try {
- System.out.println(makeInputSuggestion(input));
- } catch (SBIException e) {
- System.out.println("Faile to get suggestion for " + input.getOption());
- }
- return ;
- } else {
- String mainCmd = null;
- String subCmd = null;
- boolean needSubCmd = false;
-
- if (count > 1) {
- mainCmd = inputs[1];
- if ((needSubCmd = hasSub(mainCmd))) {
- if (count > 2) {
- subCmd = inputs[2];
- }
+ String mainCmd = null;
+ String subCmd = null;
+ boolean needSubCmd = false;
+
+ if (count > 1) {
+ mainCmd = inputs[1];
+ if ((needSubCmd = hasSub(mainCmd))) {
+ if (count > 2) {
+ subCmd = inputs[2];
}
}
- System.out.println(getNext(inputs, count, needSubCmd, mainCmd, subCmd));
- return ;
}
+ System.out.println(getNext(inputs, count, needSubCmd, mainCmd, subCmd));
+ return;
}
private static boolean hasSub(String mainCmd) {
}
}
}
- // make candidate strinng except duplicated options
+ // make candidate string except duplicated options
boolean isFind = false;
for (int i = 0; i < candidates.length; i++) {
candidate = candidates[i];
return duplicatedOption;
}
- private static String makeInputSuggestion(casesForInputSuggestion optionFortSuggestion) throws SBIException {
- SmartBuildInterface sbi = SmartBuildInterface.getInstance();
+ private static String makeInputSuggestion(optionSuggestion optionFortSuggestion) throws SBIException {
String suggestion = "";
- List<String> listResult = null;
switch (optionFortSuggestion) {
- case platform:
- listResult = sbi.getRootstrapList();
- break;
- case toolchain:
- listResult = sbi.getToolchainList();
- break;
- case buildtarget:
- listResult = sbi.getTargetList();
+ case architecture:
+ case compiler:
+ case configuration:
+ suggestion = optionFortSuggestion.getSuggestion();
break;
case name:
- listResult = CreateProjectCommandData.getTemplateList();
+ List<String> listResult = CreateProjectCommandData.getTemplateList();
+ for (String result : listResult) {
+ suggestion = suggestion + " " + result;
+ }
+ suggestion = suggestion.trim();
break;
-
}
- for (String result : listResult) {
- suggestion = suggestion + " " + result;
- }
- return suggestion.trim();
+ return suggestion;
}
}
-