Modify default help message to show usage.
Fix current working path error.
Change-Id: I24783c4acb7ff59b3902d002e7246fd83349f801
Signed-off-by: hyeongseok.heo <hyeongseok.heo@samsung.com>
<appender-ref ref="console" />
</logger>
+ <logger name="org.tizen.ncli.core">
+ <level value="trace"/>
+ <appender-ref ref="console" />
+ </logger>
+
<logger name="org.tizen.core.ide">
<level value="off"/>
<appender-ref ref="console" />
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<profiles version="2.2">
+ <profile name="develop">
+<!-- Please change <SDK_PATH> to the installed sdk path like '/home/user/tizen-sdk'.-->
+
+<!-- [REQUIRED] -->
+<!-- This is an author certificate. Please change key and password attributes. -->
+<!-- If you want, you can create a new certificate using the certificate-generator. -->
+ <profileitem
+ ca="<SDK_PATH>/tools/certificate-generator/certificates/developer/tizen-developer-ca.cer"
+ distributor="0"
+ key="<Your Certificate (.p12) Path>"
+ password=""
+ rootca=""/>
+
+<!-- [REQUIRED] -->
+<!-- This is a default distributor certificate for developer. -->
+<!-- Generally, you don't need to change this. -->
+ <profileitem
+ ca="<SDK_PATH>/tools/certificate-generator/certificates/distributor/tizen-distributor-ca.cer"
+ distributor="1"
+ key="<SDK_PATH>/tools/certificate-generator/certificates/distributor/tizen-distributor-signer.p12"
+ password="Vy63flx5JBMc5GA4iEf8oFy+8aKE7FX/+arrDcO4I5k="
+ rootca=""/>
+
+<!-- [OPTIONAL] -->
+<!-- Second distributor is a special purposed option. -->
+<!-- Generally, you don't need to change this. -->
+ <profileitem
+ ca=""
+ distributor="2"
+ key=""
+ password=""
+ rootca=""/>
+ </profile>
+</profiles>
import java.io.PrintWriter;
import java.io.Writer;
+import java.lang.annotation.Annotation;
import java.util.List;
import java.util.ResourceBundle;
* @return
*/
private CommandInfo parseTizenSubCommand(SubCommand subCommand) {
- TizenSubCommand annotation = subCommand.impl().getClass().getAnnotation(TizenSubCommand.class);
+ TizenSubCommand annotation = subCommand.impl().getAnnotation(TizenSubCommand.class);
log.trace("SubCommand:{}", subCommand.name());
String subCmdName = subCommand.name();
CommandInfo cmdInfo = null;
progressLog.info("-----------------------------------------------------");
progressLog.info("Starting {}", getCurrCmdName());
progressLog.info("-----------------------------------------------------");
+ progressLog.info("");
}
private void printFinished() {
if( !isLoggingStartFinish) return;
progressLog.info("-----------------------------------------------------");
progressLog.info("Finished {}", getCurrCmdName());
- progressLog.info("-----------------------------------------------------");
+ progressLog.info("");
}
private String getCurrCmdName() {
import org.tizen.ncli.ide.subcommands.BuildNativeCLICommand;\r
\r
/**\r
- * @author Hyunsik Noh{@leteral <hyunsik.noh@samsung.com>} (S-core)\r
+ * @author Hyunsik Noh{@literal <hyunsik.noh@samsung.com>} (S-core)\r
*/\r
@TizenSubCommand(name="build-native" , usage="Build for the tizen native project")\r
public class BuildNativeCLI extends AbstractCLI {\r
\r
BuildNativeCLICommand command = new BuildNativeCLICommand();\r
\r
- command.setWorkingDir(workingDir == null ? currentWorkspacePath : workingDir);\r
+ command.setWorkingDir(getRealWorkingPath());\r
configuration = DA.equals(configuration) ? DA_ORIGIN : configuration;\r
command.setRequiredOptions(new String[]{architecture, compiler, configuration});\r
command.setPredefineOption(predefineOption);\r
public void execute() {
log.trace("Execute InstallCLI...");
InstallCLICommand command = new InstallCLICommand();
- command.setWorkingDir(workingDir == null ? currentWorkspacePath : workingDir);
+ command.setWorkingDir(getRealWorkingPath());
command.setTarget(target);
command.setName(name);
Install runCommand = command.runCommand();
public void execute() {
log.trace("Execute ListAppCLI...");
ListAppCLICommand command = new ListAppCLICommand();
- command.setWorkingDir(workingDir == null ? currentWorkspacePath : workingDir);
+ command.setWorkingDir(getRealWorkingPath());
command.setTarget(target);
ListApp runCommand = command.runCommand();
}
public class ListCLI extends AbstractCLI{
private Logger log = LoggerFactory.getLogger(getClass());
- @Argument(index = 0, required = true, handler = TizenSubCommandHandler.class, usage = "Command is needed!")
+ @Argument(index = 0, required = true, handler = TizenSubCommandHandler.class)
@SubCommands({
@SubCommand(name = "target", impl = ListTargetCLI.class),
@SubCommand(name = "app", impl = ListAppCLI.class)
log.trace("Execute ListDeviceCLI...");
ListTargetCLICommand command = new ListTargetCLICommand();
- command.setWorkingDir(workingDir == null ? currentWorkspacePath : workingDir);
+ command.setWorkingDir(getRealWorkingPath());
command.setDetail(detail);
ListTarget runCommand = command.runCommand();
}
import java.io.PrintWriter;
import java.text.MessageFormat;
+import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tizen.common.util.IOUtil;
+import org.tizen.common.util.StringUtil;
import org.tizen.ncli.core.CommandInfo;
import org.tizen.ncli.core.CommandLineParser;
import org.tizen.ncli.core.SubCommandData;
try {
if (args.length == 0 || helpOpt) {
printDefaultCommandUsage(errorWriter);
- } else if (args.length == 3) {
+ } else if (args.length == 3 ) {
String command = args[0];
log.trace("{}", command);
if (null == SubCommandData.get(command)) {
if (findTreeNode.children.size() > 0) {
errorWriter.println(MessageFormat.format("Usage: tizen {0} <sub-command> [args]", command));
List<TreeNode<CommandInfo>> children = findTreeNode.children;
+ int maxLen = getMaxLengthForTreeNode(children)+4;
for (TreeNode<CommandInfo> treeNode : children) {
- errorWriter.printf(" %s\t%s\n", treeNode.data.getCommandName(), treeNode.data.getUsage());
+ errorWriter.printf(" %-"+maxLen+"s%s\n", treeNode.data.getCommandName(), treeNode.data.getUsage());
}
} else {
errorWriter.println(MessageFormat.format("Usage: tizen {0} [args]", command));
}
}
- private void printDefaultCommandUsage(PrintWriter errorWriter) {
+ private int getMaxLengthForTreeNode(List<TreeNode<CommandInfo>> children) {
+ int ret = 0;
+ for (TreeNode<CommandInfo> treeNode : children) {
+ int currLen = ( null != treeNode.data.getCommandName())?treeNode.data.getCommandName().length():0;
+ ret = Math.max(ret, currLen);
+ }
+ return ret;
+ }
+
+ private void printDefaultCommandUsage(PrintWriter errorWriter) {
progressLog.error("Usage: tizen <command> [args]");
progressLog.error("Where <command> is one of ");
progressLog.error("-----------------------------");
Set<String> commandNames = SubCommandData.keySet();
+ int maxLen = getMaxLength(commandNames)+4;
for (String key : commandNames) {
CommandInfo commandInfo = SubCommandData.get(key);
- progressLog.error(" {}\t{}",key,(commandInfo.getUsage() == null) ? "" : commandInfo.getUsage());
+ progressLog.error(String.format(" %-"+maxLen+"s%s", key,(commandInfo.getUsage() == null) ? "" : commandInfo.getUsage()));
}
progressLog.error("See more information:\n tizen help <command>");
}
+
+ private int getMaxLength(Iterable<String> keys) {
+ int ret = 0;
+ for (String key : keys) {
+ ret = Math.max(ret, key.length());
+ }
+ return ret;
+ }
}
public void execute() {
log.trace("Execute RunCLI...");
RunCLICommand command = new RunCLICommand();
- command.setWorkingDir(workingDir == null ? currentWorkspacePath : workingDir);
+ command.setWorkingDir(getRealWorkingPath());
command.setTarget(target);
command.setPackageId(pkgId);
Run runCommand = command.runCommand();
SignCLICommand command = new SignCLICommand();\r
\r
command.setProfileName(profile);\r
- command.setWorkingDir(workingDir == null ? currentWorkspacePath : workingDir);\r
+ command.setWorkingDir(getRealWorkingPath());\r
Sign sign = command.runCommand();\r
}\r
\r
public void execute() {
log.trace("Execute UninstallCLI...");
UninstallCLICommand command = new UninstallCLICommand();
- command.setWorkingDir(workingDir == null ? currentWorkspacePath : workingDir);
+ command.setWorkingDir(getRealWorkingPath());
command.setTarget(target);
command.setPkgId(pkgId);
Uninstall runCommand = command.runCommand();