From: hyunsik.noh Date: Mon, 18 Nov 2013 10:55:12 +0000 (+0900) Subject: CLI: Fix autocompletion error and change build-native options. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F34%2F12534%2F1;p=sdk%2Ftools%2Fcli.git CLI: Fix autocompletion error and change build-native options. Fix to get args count in tizen.sh and change options for native build. Change-Id: Id9cfcad31eec708264acf87f20afec19089e1079 Signed-off-by: hyunsik.noh --- diff --git a/org.tizen.ncli.ide/src/org/tizen/ncli/ide/autocomplete/TizenAutoComplete.java b/org.tizen.ncli.ide/src/org/tizen/ncli/ide/autocomplete/TizenAutoComplete.java index 07276f3..f226bb6 100644 --- a/org.tizen.ncli.ide/src/org/tizen/ncli/ide/autocomplete/TizenAutoComplete.java +++ b/org.tizen.ncli.ide/src/org/tizen/ncli/ide/autocomplete/TizenAutoComplete.java @@ -27,7 +27,6 @@ package org.tizen.ncli.ide.autocomplete; 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; @@ -35,14 +34,22 @@ public class TizenAutoComplete { 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" }, @@ -54,19 +61,38 @@ public class TizenAutoComplete { 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() { @@ -81,39 +107,40 @@ public class TizenAutoComplete { 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) { @@ -213,7 +240,7 @@ public class TizenAutoComplete { } } } - // 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]; @@ -246,30 +273,23 @@ public class TizenAutoComplete { 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 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 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; } } - diff --git a/org.tizen.ncli.ide/tizen.sh b/org.tizen.ncli.ide/tizen.sh index 61bf5ce..d0a2be1 100755 --- a/org.tizen.ncli.ide/tizen.sh +++ b/org.tizen.ncli.ide/tizen.sh @@ -25,7 +25,7 @@ done #If there is no sub-command , do not set --current-workspace-path option. # @Added by Harry Hyeongseok Heo # 2013.11.14 -if test $ARGS +if [ ${#ARGS} -gt 0 ] then ARGS="$ARGS --current-workspace-path $CURRENT_WORKSPACE_PATH" else ARGS="" fi