Add ListAppCLI which shows installed app list on target.
Add native and web package extension variable in CLIConstant.
Change-Id: I6f5ab7258a32e317ad3a52cf8c4101fb8e490b32
Signed-off-by: hyunsik.noh <hyunsik.noh@samsung.com>
*/\r
package org.tizen.ncli.ide;\r
\r
+import org.tizen.common.TizenPlatformConstants;\r
+\r
/**\r
* @author Harry Hyeongseok Heo{@leteral <hyeongseok.heo@samsung.com>} (S-core)\r
*\r
public static final String TIZEN_CLI_LOCAL_KEY = "TIZEN.CLI.LOCAL";//Preference key\r
\r
public static final String CLI_HOME = System.getenv("CLI_HOME");\r
+ \r
+ public static String NATIVE_PKG_EXT = TizenPlatformConstants.PKGTYPE_TPK.toLowerCase();\r
+ public static String WEB_PKG_EXT = TizenPlatformConstants.PKGTYPE_WGT.toLowerCase();\r
\r
}\r
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" },
+ { "list", "device", "app" },
{ "create", "web-project nativ-project security-profile security-profile-item certificate" },
{ "help", commands } };
--- /dev/null
+/*
+ * IDE
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ */
+package org.tizen.ncli.ide.shell;
+
+import org.kohsuke.args4j.Option;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.tizen.ncli.core.TizenSubCommand;
+import org.tizen.ncli.ide.subcommands.ListApp;
+import org.tizen.ncli.ide.subcommands.ListAppCLICommand;
+/**
+ * Implemented functions of list app CLI options.
+ *
+ * @author Hyunsik Noh{@literal <hyunsik.noh@samsung.com>} (S-core)
+ */
+@TizenSubCommand(name="app" , usage="Show installed app list")
+public class ListAppCLI extends AbstractCLI{
+ private Logger log = LoggerFactory.getLogger(getClass());
+
+ @Option(name = "--target", metaVar="target name" , usage = "Show installed app list on target")
+ private String target;
+
+ @Override
+ public void execute() {
+ log.trace("Execute ListAppCLI...");
+ ListAppCLICommand command = new ListAppCLICommand();
+ command.setWorkingDir(workingDir == null ? currentWorkspacePath : workingDir);
+ command.setTarget(target);
+ ListApp runCommand = command.runCommand();
+ }
+
+}
\ No newline at end of file
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.spi.SubCommand;
-import org.kohsuke.args4j.spi.SubCommandHandler;
import org.kohsuke.args4j.spi.SubCommands;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tizen.ncli.core.TizenSubCommand;
+import org.tizen.ncli.core.TizenSubCommandHandler;
@TizenSubCommand(name="list" , usage="Show the list")
public class ListCLI extends AbstractCLI{
private Logger log = LoggerFactory.getLogger(getClass());
- @Argument(index = 0, required = true, handler = SubCommandHandler.class, usage = "Command is needed!")
+ @Argument(index = 0, required = true, handler = TizenSubCommandHandler.class, usage = "Command is needed!")
@SubCommands({
- @SubCommand(name = "device", impl = ListDeviceCLI.class)
+ @SubCommand(name = "device", impl = ListDeviceCLI.class),
+ @SubCommand(name = "app", impl = ListAppCLI.class)
})
private AbstractCLI tizenCLI;
if( null != this.tizenCLI) {
this.tizenCLI.execute();
}
-
}
}
import java.io.PrintWriter;
import java.text.MessageFormat;
-import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
-import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
-import org.kohsuke.args4j.OptionHandlerFilter;
-import org.kohsuke.args4j.spi.OptionHandler;
import org.kohsuke.args4j.spi.SubCommand;
-import org.kohsuke.args4j.spi.SubCommandHandler;
import org.kohsuke.args4j.spi.SubCommands;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tizen.ncli.core.CommandInfo;
import org.tizen.ncli.core.CommandLineParser;
import org.tizen.ncli.core.SubCommandData;
-import org.tizen.ncli.core.TizenSubCommand;
import org.tizen.ncli.core.TizenSubCommandHandler;
import org.tizen.ncli.core.collection.TreeNode;
import org.tizen.ncli.ide.messages.TizenCLIMessages;
import org.tizen.common.sdb.command.SdbCommand;
import org.tizen.common.util.HostUtil;
import org.tizen.common.util.IOUtil;
+import org.tizen.ncli.ide.CLIConstant;
import org.tizen.ncli.ide.config.ConfigConstant;
import org.tizen.ncli.ide.config.Configuration;
import org.tizen.ncli.ide.messages.TizenCLIMessages;
private String srcPath = null;
private String ext = null;
- public static String nativePkgExt = TizenPlatformConstants.PKGTYPE_TPK.toLowerCase();
- public static String webPkgExt = TizenPlatformConstants.PKGTYPE_WGT.toLowerCase();
-
private String searchPkgCommand = "ls %s | grep .%s";
private String installCommand = TizenPlatformConstants.PKG_TOOL_INSTALL_COMMAND;
log.trace("validate package");
boolean result = true;
- String[] tpks = getPackages(nativePkgExt);
+ String[] tpks = getPackages(CLIConstant.NATIVE_PKG_EXT);
int tpkCnt = (tpks != null ? tpks.length : 0);
- String[] wgts = getPackages(webPkgExt);
+ String[] wgts = getPackages(CLIConstant.WEB_PKG_EXT);
int wgtCnt = (wgts != null ? wgts.length : 0);
int pkgCnt = tpkCnt + wgtCnt;
if(pkgCnt == 1 ) {
if(tpkCnt == 1) {
//native install
srcPath = tpks[0];
- ext = nativePkgExt;
+ ext = CLIConstant.NATIVE_PKG_EXT;
} else {
//web install
srcPath = wgts[0];
- ext = webPkgExt;
+ ext = CLIConstant.WEB_PKG_EXT;
}
log.info("ext: " + ext + " package: " + srcPath);
} else {
--- /dev/null
+/*
+ * IDE
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ */
+package org.tizen.ncli.ide.subcommands;
+
+public class ListApp {
+
+}
--- /dev/null
+/*
+ * IDE
+ *
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Hyunsik Noh <hyunsik.noh@samsung.com>
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ */
+package org.tizen.ncli.ide.subcommands;
+
+import org.tizen.common.TizenPlatformConstants;
+import org.tizen.common.sdb.command.SdbCommand;
+import org.tizen.ncli.ide.CLIConstant;
+import org.tizen.ncli.ide.util.TargetUtil;
+import org.tizen.ncli.ide.config.ConfigConstant;
+import org.tizen.ncli.ide.config.Configuration;
+import org.tizen.ncli.ide.messages.TizenCLIMessages;
+import org.tizen.sdblib.IDevice;
+
+/**
+ * This class provides required functions to installed app list on target.
+ *
+ * @author Hyunsik Noh{@literal <hyunsik.noh@samsung.com>} (S-core)
+ */
+public class ListAppCLICommand extends AbstractSubCommand<ListApp> {
+ private Configuration config;
+ private IDevice target = null;
+ private String listAppCommand = TizenPlatformConstants.PKG_TOOL + " -l -t %s";
+
+ private final String PKG_TYPE = "pkg_type";
+
+ public ListAppCLICommand() {
+ config = new Configuration();
+ }
+
+ @Override
+ protected ListApp call() {
+ if(target != null) {
+ getAppList(CLIConstant.NATIVE_PKG_EXT);
+ getAppList(CLIConstant.WEB_PKG_EXT);
+ } else {
+ System.out.println(TizenCLIMessages.FAIL_TARGET);
+ }
+ return null;
+ }
+
+ public void setTarget(String targetName) {
+ target = TargetUtil.getTarget(targetName);
+ }
+
+ private void getAppList(String pkgtype) {
+ log.trace("get app list");
+ String result = null;
+ String listAppCmd = String.format(listAppCommand, pkgtype);
+ String defaultTimeout = config.getValue(ConfigConstant.DEFAULT_SDB_TIMEOUT);
+ int timeout = (defaultTimeout == null ? 60000 : Integer.parseInt(defaultTimeout));
+ log.debug("[List App]: " + listAppCmd);
+ SdbCommand sdbCommand = new SdbCommand(target, null, null, timeout);
+ result = sdbCommand.returnExecuteCommand(listAppCmd);
+ setAppList(result);
+ }
+
+ private void setAppList(String returnExecute) {
+ String[] lines = returnExecute.split("\n");
+ for(String line: lines) {
+ if(line.startsWith(PKG_TYPE)) {
+ System.out.println(line);
+ }
+ }
+ }
+}