CLI: Add time printer. 39/13739/3
authorhyunsik.noh <hyunsik.noh@samsung.com>
Fri, 13 Dec 2013 07:54:10 +0000 (16:54 +0900)
committerhyunsik.noh <hyunsik.noh@samsung.com>
Tue, 17 Dec 2013 05:01:47 +0000 (14:01 +0900)
Add time printer.
Hide pkgcmd return string for RunCLICommand.java

Change-Id: I63da23926705aad92744be1ecc2eba2382d1919d
Signed-off-by: hyunsik.noh <hyunsik.noh@samsung.com>
org.tizen.ncli.ide/src/org/tizen/ncli/ide/autocomplete/TizenAutoComplete.java
org.tizen.ncli.ide/src/org/tizen/ncli/ide/messages/TizenCLIMessages.java
org.tizen.ncli.ide/src/org/tizen/ncli/ide/messages/TizenCLIMessages.properties
org.tizen.ncli.ide/src/org/tizen/ncli/ide/shell/BuildNativeCLI.java
org.tizen.ncli.ide/src/org/tizen/ncli/ide/shell/InstallCLI.java
org.tizen.ncli.ide/src/org/tizen/ncli/ide/shell/SignCLI.java
org.tizen.ncli.ide/src/org/tizen/ncli/ide/shell/UninstallCLI.java
org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/InstallCLICommand.java
org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/RunCLICommand.java

index d3bb59e..b186788 100644 (file)
@@ -46,9 +46,9 @@ public class TizenAutoComplete {
         { "build-web", "--output -opt --optimize -euf --exclude-uifw -efum --exclude-uifw-min" },
         { "sign", "--profile" },
         { "package", "--type --sign -ref --ref-project" },
-        { "install", "--target" },
-        { "uninstall", "--target --pkgid" },
-        { "run", "--target --pkgid"},
+        { "install", "--target -n --name" },
+        { "uninstall", "--target --pkgId" },
+        { "run", "--target --pkgId"},
         { "debug", "--target" }
         };
 
index 9c301e2..fc4fd1b 100644 (file)
@@ -66,6 +66,9 @@ public class TizenCLIMessages extends NLS {
     
   //RUN(RUN)
     public static String RUN_FAIL_CANNOT_FIND_APP_NAME;
+    public static String RUN_LAUNCHING_PACKAGE;
+    public static String RUN_SUCCESS_PACKAGE;
+    public static String RUN_FAIL_PACKAGE;
     
     //LIST
     public static String LIST_NO_DEVICE;
index b70a99b..062422d 100644 (file)
@@ -51,3 +51,6 @@ UNINST_FAIL_NO_PACKAGE_ID = [Fail] Fail uninstall. There is no package id.
 RUN_FAIL_CANNOT_FIND_APP_NAME = [Fail]Can not find app name.
 
 LIST_NO_DEVICE = There is no device.
+RUN_LAUNCHING_PACKAGE = Launching the Tizen application...
+RUN_SUCCESS_PACKAGE = Tizen application is successfully launched.
+RUN_FAIL_PACKAGE = Could not launch the {0} application.
\ No newline at end of file
index a72d9c5..3092c6f 100644 (file)
@@ -71,5 +71,9 @@ public class BuildNativeCLI extends AbstractCLI {
 \r
         BuildNative runCommand = command.runCommand();\r
     }\r
+    \r
+    public boolean needPrintTime() {\r
+        return true;\r
+    }\r
 \r
 }
\ No newline at end of file
index 4723eb7..9c2374d 100644 (file)
@@ -42,13 +42,21 @@ public class InstallCLI extends AbstractCLI{
     @Option(name = "--target", usage = "Target to install the package")
     private String target;
     
+    @Option(name = "--name", aliases ="-n",  usage = "The package name to install")
+    private String name;
+    
     @Override
     public void execute() {
         log.trace("Execute InstallCLI...");
         InstallCLICommand command = new InstallCLICommand();
         command.setWorkingDir(workingDir == null ? currentWorkspacePath : workingDir);
         command.setTarget(target);
+        command.setName(name);
         Install runCommand = command.runCommand();
     }
+    
+    public boolean needPrintTime() {
+        return true;
+    }
 
 }
index 045057d..98739b4 100644 (file)
@@ -48,4 +48,8 @@ public class SignCLI extends AbstractCLI {
         command.setWorkingDir(workingDir == null ? currentWorkspacePath : workingDir);\r
         Sign sign = command.runCommand();\r
     }\r
+    \r
+    public boolean needPrintTime() {\r
+        return true;\r
+    }\r
 }\r
index 4932ba7..ecaa719 100644 (file)
@@ -41,7 +41,7 @@ public class UninstallCLI extends AbstractCLI{
     
     @Option(name = "--target", usage = "Target to uninstall the package")
     private String target;
-    @Option(name = "--pkgid", usage = "Package Id to uninstall")
+    @Option(name = "--pkgId", usage = "Package Id to uninstall")
     private String pkgId;
     
     @Override
@@ -53,5 +53,9 @@ public class UninstallCLI extends AbstractCLI{
         command.setPkgId(pkgId);
         Uninstall runCommand = command.runCommand();
     }
+    
+    public boolean needPrintTime() {
+        return true;
+    }
 
 }
index 4b140a5..7440dfc 100644 (file)
@@ -93,6 +93,11 @@ public class InstallCLICommand extends AbstractSubCommand<Install> {
         log.debug("[target]: " + (target == null ? "null" : targetSerialId));
     }
     
+    public void setName(String name) {
+        this.name = name;
+        log.debug("[name]: " + name);
+    }
+
     private boolean isValidPackage() {
         log.trace("=validate package=");
         boolean result = true;
index e561bf4..52f768d 100644 (file)
@@ -24,6 +24,7 @@
  */
 package org.tizen.ncli.ide.subcommands;
 
+import org.eclipse.osgi.util.NLS;
 import org.tizen.ncli.ide.CLIConstant;
 import org.tizen.ncli.ide.messages.TizenCLIMessages;
 import org.tizen.ncli.ide.util.TargetUtil;
@@ -40,26 +41,30 @@ public class RunCLICommand extends AbstractSubCommand<Run> {
     private String appTypeCommand = "/usr/bin/pkginfo --pkg %s | grep -i Type";
     private String runNativeAppCommand = "launch_app %s.%s";
     private String runWebAppCommand = "/usr/bin/wrt-launcher --s %s.%s --t 60000";
+    private final String SUCCESS= "result: launched";
     
     public RunCLICommand() {
     }
     
     @Override
     protected Run call() {
-        progressLog.info("[Start] Run Tizen App");
         if(target != null) {
             appName = getAppName();
             appType = getAppType();
             if(appName != null && appType != null ) {
                 //run
-                runApp();
+                if(runApp()) {
+                    progressLog.info(TizenCLIMessages.RUN_SUCCESS_PACKAGE);
+                } else {
+                    String appId = pkgId + "." + appName;
+                    progressLog.info(NLS.bind(TizenCLIMessages.RUN_FAIL_PACKAGE, appId));
+                }
             } else {
                 progressLog.info(TizenCLIMessages.RUN_FAIL_CANNOT_FIND_APP_NAME);
             }
         } else {
             progressLog.info(TizenCLIMessages.FAIL_TARGET);
         }
-        progressLog.info("[End] Run Tizen App");
         return null;
     }
     
@@ -114,9 +119,10 @@ public class RunCLICommand extends AbstractSubCommand<Run> {
         return appType;
     }
 
-    private String runApp() {
+    private boolean runApp() {
+        boolean result = false;
         log.info("=run app=");
-        String result = null;
+        progressLog.info(TizenCLIMessages.RUN_LAUNCHING_PACKAGE);
         String runCommand = null;
         if(CLIConstant.NATIVE_PKG_EXT.equals(appType)) {
             runCommand = String.format(runNativeAppCommand, pkgId, appName);
@@ -124,8 +130,14 @@ public class RunCLICommand extends AbstractSubCommand<Run> {
             runCommand = String.format(runWebAppCommand, pkgId, appName);
         }
         log.debug("[Run Command]]: " + runCommand);
-        result = TargetUtil.getDefault().returnExecuteCommand(target, runCommand);
-        progressLog.info(result);
+        String returnResult = TargetUtil.getDefault().returnExecuteCommand(target, runCommand);
+        String[] tokens = returnResult.split("\n");
+        for(String token : tokens) {
+            if(SUCCESS.equals(token)) {
+                result = true;
+                break;
+            }
+        }
         return result;
     }
 }