--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry kind="lib" path="lib/args4j-2.0.24-SNAPSHOT.jar" sourcepath="/args4j/args4j/src"/>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>\r
+ <classpathentry kind="src" path="src"/>\r
+ <classpathentry kind="src" path="test/src"/>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>\r
+ <classpathentry kind="output" path="bin"/>\r
+</classpath>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>org.tizen.ncli.ide</name>\r
+ <comment></comment>\r
+ <projects>\r
+ </projects>\r
+ <buildSpec>\r
+ <buildCommand>\r
+ <name>org.eclipse.jdt.core.javabuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.eclipse.pde.ManifestBuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.eclipse.pde.SchemaBuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ </buildSpec>\r
+ <natures>\r
+ <nature>org.eclipse.pde.PluginNature</nature>\r
+ <nature>org.eclipse.jdt.core.javanature</nature>\r
+ </natures>\r
+</projectDescription>\r
--- /dev/null
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate\r
+org.eclipse.jdt.core.compiler.debug.localVariable=generate\r
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.6\r
--- /dev/null
+eclipse.preferences.version=1\r
+pluginProject.extensions=false\r
+resolve.requirebundle=false\r
--- /dev/null
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Newcli-prototype
+Bundle-SymbolicName: org.tizen.ncli.ide
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: org.tizen.common;bundle-version="2.0.0"
--- /dev/null
+source.. = src/\r
+output.. = bin/\r
+bin.includes = META-INF/,\\r
+ .\r
--- /dev/null
+#!/bin/sh
+# Copyright (C) 2008-2009, Google Inc.
+# Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
+# and other copyright owners as documented in the project's IP log.
+#
+# This program and the accompanying materials are made available
+# under the terms of the Eclipse Distribution License v1.0 which
+# accompanies this distribution, is reproduced below, and is
+# available at http://www.eclipse.org/org/documents/edl-v10.php
+#
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or
+# without modification, are permitted provided that the following
+# conditions are met:
+#
+# - Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# - Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following
+# disclaimer in the documentation and/or other materials provided
+# with the distribution.
+#
+# - Neither the name of the Eclipse Foundation, Inc. nor the
+# names of its contributors may be used to endorse or promote
+# products derived from this software without specific prior
+# written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+cmd=
+for a in "$@"
+do
+ case "$a" in
+ -*) continue ;;
+ *) cmd=$a; break; ;;
+ esac
+done
+
+use_pager=
+case "$cmd" in
+blame) use_pager=1 ;;
+diff) use_pager=1 ;;
+log) use_pager=1 ;;
+esac
+
+this_script=`which "$0" 2>/dev/null`
+[ $? -gt 0 -a -f "$0" ] && this_script="$0"
+cp=$this_script
+
+if [ -n "$JGIT_CLASSPATH" ]
+then
+ cp="$cp:$JGIT_CLASSPATH"
+fi
+
+# Cleanup paths for Cygwin.
+#
+case "`uname`" in
+CYGWIN*)
+ cp=`cygpath --windows --mixed --path "$cp"`
+ ;;
+Darwin)
+ if [ -e /System/Library/Frameworks/JavaVM.framework ]
+ then
+ java_args='
+ -Dcom.apple.mrj.application.apple.menu.about.name=JGit
+ -Dcom.apple.mrj.application.growbox.intrudes=false
+ -Dapple.laf.useScreenMenuBar=true
+ -Xdock:name=JGit
+ -Dfile.encoding=UTF-8
+ '
+ fi
+ ;;
+esac
+
+CLASSPATH="$cp"
+export CLASSPATH
+
+java=java
+if [ -n "$JAVA_HOME" ]
+then
+ java="$JAVA_HOME/bin/java"
+fi
+
+if [ -n "$use_pager" ]
+then
+ use_pager=${GIT_PAGER:-${PAGER:-less}}
+ [ cat = "$use_pager" ] && use_pager=
+fi
+
+if [ -n "$use_pager" ]
+then
+ LESS=${LESS:-FSRX}
+ export LESS
+
+ "$java" $java_args org.eclipse.jgit.pgm.Main "$@" | $use_pager
+ exit
+else
+ exec "$java" $java_args org.eclipse.jgit.pgm.Main "$@"
+ exit 1
+fi
--- /dev/null
+/*\r
+ * IDE\r
+ *\r
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ */\r
+package org.tizen.ncli.ide;\r
+\r
+/**\r
+ * @author Harry Hyeongseok Heo{@leteral <hyeongseok.heo@samsung.com>} (S-core)\r
+ *\r
+ */\r
+public class CLIConstant {\r
+ \r
+ public static final String TIZEN_CLI_GLOBAL_KEY = "TIZEN.CLI.GLOBAL";//Preference key\r
+ public static final String TIZEN_CLI_LOCAL_KEY = "TIZEN.CLI.LOCAL";//Preference key\r
+\r
+}\r
--- /dev/null
+/**\r
+ * \r
+ */\r
+package org.tizen.ncli.ide;\r
+\r
+import org.tizen.ncli.ide.core.command.CreateCommand;\r
+import org.tizen.ncli.ide.core.command.SetConfigCommand;\r
+import org.tizen.ncli.ide.subcommands.ConfigCLICommand;\r
+\r
+\r
+/**\r
+ * This class offers Tizen CLI command with API level\r
+ * @author Hyeongseok Heo\r
+ *\r
+ */\r
+public class Tizen {\r
+ \r
+ public Tizen() {\r
+ \r
+ }\r
+ \r
+\r
+ @SuppressWarnings("rawtypes")\r
+ public CreateCommand<?> create(){\r
+ return new CreateCommand();\r
+ }\r
+\r
+ /**\r
+ * @return config command instance\r
+ */\r
+ public ConfigCLICommand config() {\r
+ return new ConfigCLICommand();\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * IDE\r
+ *\r
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ */\r
+package org.tizen.ncli.ide;\r
+\r
+import java.io.File;\r
+\r
+import org.tizen.common.config.Preference;\r
+import org.tizen.common.config.PreferenceProvider;\r
+\r
+/**\r
+ * @author Harry Hyeongseok Heo{@leteral <hyeongseok.heo@samsung.com>} (S-core)\r
+ */\r
+public class TizenCLIConfig {\r
+ \r
+ public TizenCLIConfig(File configfile) {\r
+ }\r
+\r
+ /**\r
+ * \r
+ */\r
+ public TizenCLIConfig() {\r
+ // TODO Auto-generated constructor stub\r
+ }\r
+ \r
+ \r
+ \r
+ \r
+\r
+}\r
--- /dev/null
+/*\r
+ * IDE\r
+ *\r
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ */\r
+package org.tizen.ncli.ide.config;\r
+\r
+import java.util.Collection;\r
+import java.util.Collections;\r
+\r
+import org.tizen.common.config.Preference;\r
+import org.tizen.common.util.CollectionUtil;\r
+import org.tizen.ncli.ide.CLIConstant;\r
+\r
+/**\r
+ * This class represents Tizen CLI config information.\r
+ * \r
+ * @author Harry Hyeongseok Heo{@literal <hyeongseok.heo@samsung.com>} (S-core)\r
+ */\r
+public class CLIConfig {\r
+ \r
+ private Collection<String> globalKeys;\r
+ private Collection<String> localKeys;\r
+\r
+\r
+ public CLIConfig() {\r
+ setConfigValues();\r
+ }\r
+ \r
+ /**\r
+ * \r
+ */\r
+ private void setConfigValues() {\r
+ globalKeys = Preference.list("TIZEN.CLI.GLOBAL");\r
+ localKeys = Preference.list("TIZEN.CLI.LOCAL");\r
+ }\r
+\r
+ \r
+ public Collection<String> getGlobalKeys(){\r
+ return globalKeys;\r
+ }\r
+ \r
+ public Collection<String> getLocalKeys(){\r
+ return localKeys;\r
+ }\r
+ \r
+ public String getValue(String key) {\r
+ if( null != localKeys && localKeys.contains(key)) {\r
+ return Preference.get(CLIConstant.TIZEN_CLI_LOCAL_KEY, key);\r
+ }else if ( null != globalKeys && globalKeys.contains(key)) {\r
+ return Preference.get(CLIConstant.TIZEN_CLI_GLOBAL_KEY, key);\r
+ }\r
+ return null;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * IDE\r
+ *\r
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ */\r
+package org.tizen.ncli.ide.config;\r
+\r
+/**\r
+ * This class provids CLI config key name constant.\r
+ * \r
+ * @author Harry Hyeongseok Heo{@literal <hyeongseok.heo@samsung.com>} (S-core)\r
+ *\r
+ */\r
+public class ConfigConstant {\r
+ public static final String KEY = "";\r
+\r
+}\r
--- /dev/null
+/*\r
+ * IDE\r
+ *\r
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ */\r
+package org.tizen.ncli.ide.core.command;\r
+\r
+import org.tizen.common.core.command.ExecutionContext;\r
+import org.tizen.common.core.command.Executor;\r
+import org.tizen.ncli.ide.shell.CreateCLI;\r
+\r
+\r
+/**\r
+ * @author Harry Hyeongseok Heo{@leteral <hyeongseok.heo@samsung.com>} (S-core)\r
+ * @param <T>\r
+ */\r
+public class CreateCommand<T> extends TizenCommand<T> {\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.tizen.common.core.command.Command#run(org.tizen.common.core.command.Executor, org.tizen.common.core.command.ExecutionContext)\r
+ */\r
+ @Override\r
+ public void run(Executor executor, ExecutionContext context) throws Exception {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.tizen.common.core.command.Command#undo(org.tizen.common.core.command.Executor, org.tizen.common.core.command.ExecutionContext)\r
+ */\r
+ @Override\r
+ public void undo(Executor executor, ExecutionContext context) throws Exception {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.tizen.common.core.command.Command#getResult()\r
+ */\r
+ @Override\r
+ public T getResult() {\r
+ // TODO Auto-generated method stub\r
+ return null;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * IDE\r
+ *\r
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ */\r
+package org.tizen.ncli.ide.core.command;\r
+\r
+import org.tizen.common.core.command.AbstractCommand;\r
+import org.tizen.common.core.command.ExecutionContext;\r
+import org.tizen.common.core.command.Executor;\r
+import org.tizen.common.core.command.file.WriteFileCommand;\r
+\r
+/**\r
+ * @author Harry Hyeongseok Heo{@leteral <hyeongseok.heo@samsung.com>} (S-core)\r
+ */\r
+public class SaveConfigFileCommand extends AbstractCommand<Object>{\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.tizen.common.core.command.AbstractCommand#run(org.tizen.common.core.command.Executor, org.tizen.common.core.command.ExecutionContext)\r
+ */\r
+ @Override\r
+ public void run(Executor executor, ExecutionContext context) throws Exception {\r
+ \r
+ \r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * IDE\r
+ *\r
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ */\r
+package org.tizen.ncli.ide.core.command;\r
+\r
+import java.util.Map;\r
+\r
+import org.tizen.common.config.PreferenceProvider;\r
+import org.tizen.common.core.command.AbstractCommand;\r
+import org.tizen.common.core.command.CompositeCommand;\r
+import org.tizen.common.core.command.ExecutionContext;\r
+import org.tizen.common.core.command.Executor;\r
+import org.tizen.common.file.FileHandler;\r
+import org.tizen.ncli.ide.core.config.TizenCLIConfigProvider;\r
+\r
+/**\r
+ * This class handles setting and saving cli config to specific file.\r
+ * \r
+ * @author Harry Hyeongseok Heo{@leteral <hyeongseok.heo@samsung.com>} (S-core)\r
+ *\r
+ */\r
+public class SetConfigCommand extends AbstractCommand<Object>{\r
+ private static final String CONFIG_FILE_NAME = ".tizen-cli-config";\r
+ \r
+ \r
+ /**\r
+ * @param key\r
+ * @param value\r
+ */\r
+ public void setConfig(String key, String value) {\r
+ }\r
+ \r
+ public void setConfig(Map keyValueMap) {\r
+ \r
+ }\r
+\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.tizen.common.core.command.Command#run(org.tizen.common.core.command.Executor, org.tizen.common.core.command.ExecutionContext)\r
+ */\r
+ @Override\r
+ public void run(Executor executor, ExecutionContext context) throws Exception {\r
+ FileHandler fileHandler = context.getFileHandler();\r
+// WriteFileCommand writeFileCmd = new WriteFileCommand(path, contents);\r
+ \r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.tizen.common.core.command.Command#undo(org.tizen.common.core.command.Executor, org.tizen.common.core.command.ExecutionContext)\r
+ */\r
+ @Override\r
+ public void undo(Executor executor, ExecutionContext context) throws Exception {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+ \r
+\r
+}\r
--- /dev/null
+/*\r
+ * IDE\r
+ *\r
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ */\r
+package org.tizen.ncli.ide.core.command;\r
+\r
+import org.tizen.common.core.command.Command;\r
+\r
+/**\r
+ * Abstract class for CLI command classes.\r
+ * \r
+ * @author Harry Hyeongseok Heo{@leteral <hyeongseok.heo@samsung.com>} (S-core)\r
+ * @param <T>\r
+ *\r
+ */\r
+public abstract class TizenCommand<T> implements Command<T>{\r
+ \r
+ protected T result;\r
+ \r
+ \r
+}\r
--- /dev/null
+/*\r
+ * IDE\r
+ *\r
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ */\r
+package org.tizen.ncli.ide.core.config;\r
+\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.FileNotFoundException;\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+import java.util.Properties;\r
+\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.tizen.common.config.Loader;\r
+import org.tizen.common.config.Preference;\r
+import org.tizen.common.core.application.InstallPathConfig;\r
+import org.tizen.common.util.Assert;\r
+import org.tizen.common.util.FileUtil;\r
+import org.tizen.common.util.IOUtil;\r
+import org.tizen.ncli.ide.CLIConstant;\r
+\r
+/**\r
+ * This class loads Tizen configuration from the specified file <tt>.tizen-cli-config</tt> .\r
+ * \r
+ * <p>Tizen configuration file could be located at two location. <br>\r
+ * First, global configuration file is located under the <tt>user home</tt> location.In Windows it would be C:\Users\accountName.\r
+ * <br>\r
+ * Second, local configuration file is located under the <tt>Tizen SDK tools path</tt>.<br>\r
+ * <br> \r
+ * Make sure that local config will have high priority to global config if there is same key. \r
+ * @author Harry Hyeongseok Heo{@literal <hyeongseok.heo@samsung.com>} (S-core)\r
+ */\r
+public class NCLIConfigLoader implements Loader {\r
+ private static final String configFileName =".tizen-cli-config";\r
+ private static Logger log = LoggerFactory.getLogger(NCLIConfigLoader.class);\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.tizen.common.config.Loader#load(java.lang.String)\r
+ */\r
+ @Override\r
+ public void load(String ns) throws IOException {\r
+ Assert.notNull(ns,"Namespace could not be null");\r
+ if(CLIConstant.TIZEN_CLI_GLOBAL_KEY.equals(ns)) {\r
+ Preference.register(ns, new TizenCLIConfigProvider(loadGlobalConf()));\r
+ }else if(CLIConstant.TIZEN_CLI_LOCAL_KEY.equals(ns)) {\r
+ Preference.register(ns, new TizenCLIConfigProvider(loadLocalConf()));\r
+ }\r
+ }\r
+ \r
+ \r
+ /**\r
+ * Load local configuration from <tt>Tizen SDK Tools</tt>\r
+ * @return localProperties return null if config file not exist. \r
+ */\r
+ public static Properties loadLocalConf(){\r
+ InputStream inStream = null;\r
+ Properties localProp = null;\r
+ try {\r
+ File file = getLocalConfigFile();\r
+ boolean isLocalConfExist = file.exists();\r
+ log.trace("isLocalConfExist:{}",isLocalConfExist);\r
+ if(isLocalConfExist) {\r
+ inStream = new FileInputStream(file);\r
+ localProp = new Properties();\r
+ localProp.load(inStream);\r
+ }\r
+ \r
+ }catch (FileNotFoundException e) {\r
+ //FIXME something to do\r
+ }catch(IOException io){\r
+ //FIXME something to do\r
+ }finally {\r
+ IOUtil.tryClose(inStream);\r
+ }\r
+ return localProp;\r
+ }\r
+\r
+ public static File getLocalConfigFile() {\r
+ String sdkToolPath = InstallPathConfig.getToolsPath();\r
+ return new File(sdkToolPath+"/"+configFileName);\r
+ }\r
+ /**\r
+ * Load global configuration from <tt>USER HOME</tt>\r
+ * @return globalProperties return null if config file not exist.\r
+ */\r
+ public static Properties loadGlobalConf(){\r
+ InputStream inStream = null;\r
+ Properties prop = new Properties();\r
+ try {\r
+ File file = getGlobalConfigFile();\r
+ boolean isGlobalConfExist = file.exists();\r
+ log.trace("isGlobalConfExist:{}",isGlobalConfExist);\r
+ if(isGlobalConfExist) {\r
+ inStream = new FileInputStream(file);\r
+ prop.load(inStream);\r
+ } else {\r
+ log.info("Tizen CLI Global config file does not exist."); \r
+ }\r
+ }catch (FileNotFoundException e) {\r
+ //FIXME something to do\r
+ }catch(IOException io){\r
+ //FIXME something to do\r
+ }finally {\r
+ IOUtil.tryClose(inStream);\r
+ }\r
+ return prop;\r
+ \r
+ }\r
+\r
+ public static File getGlobalConfigFile() {\r
+ File userHome = new File(System.getProperty("user.home"));\r
+ return new File(userHome.getAbsolutePath()+"/"+configFileName);\r
+ }\r
+ \r
+ \r
+\r
+}\r
--- /dev/null
+/*\r
+ * IDE\r
+ *\r
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ */\r
+package org.tizen.ncli.ide.core.config;\r
+\r
+import java.util.Collection;\r
+import java.util.Properties;\r
+\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.tizen.common.config.PreferenceProvider;\r
+import org.tizen.common.config.provider.PropertiesProvider;\r
+\r
+/**\r
+ * This class provides Tizen CLI config information based on {@link PropertiesProvider} \r
+ * @author Harry Hyeongseok Heo{@literal <hyeongseok.heo@samsung.com>} (S-core)\r
+ */\r
+public class TizenCLIConfigProvider implements PreferenceProvider{\r
+ private PropertiesProvider propProvider = null;\r
+ \r
+ public TizenCLIConfigProvider(Properties props) {\r
+ this.propProvider = new PropertiesProvider(props);\r
+ }\r
+ \r
+\r
+ /* (non-Javadoc)\r
+ * @see org.tizen.common.config.PreferenceProvider#keys()\r
+ */\r
+ @Override\r
+ public Collection<String> keys() {\r
+ return this.propProvider.keys();\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.tizen.common.config.PreferenceProvider#get(java.lang.String)\r
+ */\r
+ @Override\r
+ public String get(String key) {\r
+ return this.propProvider.get(key);\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.tizen.common.config.PreferenceProvider#set(java.lang.String, java.lang.String)\r
+ */\r
+ @Override\r
+ public void set(String key, String value) {\r
+ this.propProvider.set(key, value);\r
+ }\r
+ \r
+ \r
+\r
+}\r
--- /dev/null
+/*\r
+ * IDE\r
+ *\r
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ */\r
+package org.tizen.ncli.ide.exec;\r
+\r
+import org.tizen.common.core.command.Executor;\r
+\r
+/**\r
+ * @author Harry Hyeongseok Heo{@leteral <hyeongseok.heo@samsung.com>} (S-core)\r
+ */\r
+public class NewCommandLineExecutor extends Executor {\r
+ \r
+ /**\r
+ * \r
+ */\r
+ public NewCommandLineExecutor() {\r
+ \r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * IDE\r
+ *\r
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ */\r
+package org.tizen.ncli.ide.shell;\r
+\r
+import java.io.File;\r
+import java.io.PrintWriter;\r
+\r
+import org.kohsuke.args4j.CmdLineException;\r
+import org.kohsuke.args4j.CmdLineParser;\r
+import org.kohsuke.args4j.Option;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+/**\r
+ * Implemented common function of CLI options\r
+ * @author Harry Hyeongseok Heo{@leteral <hyeongseok.heo@samsung.com>} (S-core)\r
+ */\r
+public abstract class AbstractCLI {\r
+ protected Logger log = LoggerFactory.getLogger(getClass());\r
+ \r
+ @Option(name="--" , metaVar="target path" , usage="Specify where the root path for the command")\r
+ public File targetPath;\r
+ \r
+ protected PrintWriter output = new PrintWriter(System.out);;\r
+ \r
+ public final void execute(String[] args) {\r
+ parseArgument(args);\r
+ execute();\r
+ }\r
+ \r
+ /**\r
+ * @param args\r
+ */\r
+ private void parseArgument(String[] args) {\r
+ log.trace("Could not use parsing argument again!");\r
+// log.trace("parseArgument...");\r
+// CmdLineParser parser = new CmdLineParser(this);\r
+// \r
+// try {\r
+// parser.parseArgument(args);\r
+// } catch (CmdLineException e) {\r
+// e.printStackTrace();\r
+// System.err.println("Error occurred during parsing the arguments.");\r
+// System.exit(1);\r
+// }\r
+ }\r
+\r
+ public abstract void execute();\r
+}\r
--- /dev/null
+/*\r
+ * IDE\r
+ *\r
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ */\r
+package org.tizen.ncli.ide.shell;\r
+\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+/**\r
+ * @author Harry Hyeongseok Heo{@leteral <hyeongseok.heo@samsung.com>} (S-core)\r
+ */\r
+public class BuildNativeCLI extends AbstractCLI{\r
+ private Logger log = LoggerFactory.getLogger(getClass());\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.tizen.ncli.ide.shell.AbstractCLI#execute()\r
+ */\r
+ @Override\r
+ public void execute() {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+}\r
--- /dev/null
+package org.tizen.ncli.ide.shell;\r
+\r
+import org.kohsuke.args4j.Option;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.tizen.ncli.ide.TizenCLIConfig;\r
+import org.tizen.ncli.ide.core.command.TizenCommand;\r
+\r
+\r
+public class BuildWebCLI extends AbstractCLI{\r
+ private Logger log = LoggerFactory.getLogger(getClass());\r
+ \r
+ @Option(name="--optimize" , usage="Optimize option" )\r
+ private String optimize;\r
+ \r
+ \r
+ \r
+ public void execute() {\r
+ \r
+ }\r
+ \r
+\r
+}\r
--- /dev/null
+/*\r
+ * IDE\r
+ *\r
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ */\r
+package org.tizen.ncli.ide.shell;\r
+\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import org.kohsuke.args4j.Argument;\r
+import org.kohsuke.args4j.CmdLineException;\r
+import org.kohsuke.args4j.CmdLineParser;\r
+import org.kohsuke.args4j.Option;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.tizen.ncli.ide.Tizen;\r
+import org.tizen.ncli.ide.TizenCLIConfig;\r
+import org.tizen.ncli.ide.config.CLIConfig;\r
+import org.tizen.ncli.ide.core.command.SetConfigCommand;\r
+import org.tizen.ncli.ide.subcommands.ConfigCLICommand;\r
+\r
+\r
+/**\r
+ * @author Harry Hyeongseok Heo{@literal <hyeongseok.heo@samsung.com>} (S-core)\r
+ */\r
+public class ConfigCLI extends AbstractCLI{\r
+ private Map<String, String> properties = new HashMap<String, String>();\r
+ \r
+ @Argument\r
+ private void setConfigProperty(final String property) throws CmdLineException {\r
+ log.trace("setConfigProperty {}",property);\r
+ if( null == property || property.startsWith("-")) return;\r
+ String[] arr = property.split("=");\r
+ if(arr.length != 2) {\r
+ throw new CmdLineException("Properties must be specified in the form:"+\r
+ "<property>=<value>");\r
+ }\r
+ properties.put(arr[0], arr[1]);\r
+ }\r
+ \r
+ @Option (name="-l", aliases="--list", usage="Show config list")\r
+ public boolean list;\r
+ \r
+ @Option (name="-g" , aliases="--global", usage="Setting global Tizen CLI config")\r
+ public boolean global;\r
+ \r
+ \r
+ public void execute() {\r
+ log.trace("Execute configCLI...");\r
+ ConfigCLICommand configCommand = new Tizen().config();\r
+ \r
+ //Setting options\r
+ configCommand.setList(list);\r
+ configCommand.setGlobal(global);\r
+ configCommand.setKeyValue(properties);\r
+ \r
+ CLIConfig tizenCLIConfig = configCommand.runCommand();\r
+ //Printout result of command \r
+ if(list) {\r
+ //TODO print message should be refined \r
+ output.format("list config key values....{}", tizenCLIConfig);\r
+ }else if(global){\r
+ output.format("Setting global configuration is succeeded....");\r
+ }else {\r
+ output.format("Setting configuration is succeeded....");\r
+ }\r
+ \r
+ output.flush();\r
+ \r
+ \r
+ \r
+ }\r
+}\r
--- /dev/null
+package org.tizen.ncli.ide.shell;\r
+\r
+import org.kohsuke.args4j.Argument;\r
+import org.kohsuke.args4j.spi.SubCommand;\r
+import org.kohsuke.args4j.spi.SubCommandHandler;\r
+import org.kohsuke.args4j.spi.SubCommands;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+\r
+\r
+public class CreateCLI extends AbstractCLI {\r
+ private Logger log = LoggerFactory.getLogger(CreateCLI.class);\r
+ \r
+ @Argument(index = 0, required = true, handler = SubCommandHandler.class, usage = "Command is needed!")\r
+ @SubCommands({ \r
+ @SubCommand(name = "project", impl = CreateProject.class),\r
+ @SubCommand(name = "security-profile", impl = CreateSecProfileCLI.class),\r
+ @SubCommand(name = "security-profile-item", impl = CreateSecProfileItemCLI.class),\r
+ @SubCommand(name = "certificate", impl = CreateCertificateCLI.class)\r
+ })\r
+ private AbstractCLI tizenCLI;\r
+ \r
+ \r
+ /* (non-Javadoc)\r
+ * @see org.tizen.ncli.ide.shell.TizenCLI#execute()\r
+ */\r
+ @Override\r
+ public void execute() {\r
+ log.trace("execute Create cli...");\r
+ }\r
+ \r
+ \r
+ \r
+ \r
+}\r
--- /dev/null
+/*\r
+ * IDE\r
+ *\r
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ */\r
+package org.tizen.ncli.ide.shell;\r
+\r
+/**\r
+ * @author Harry Hyeongseok Heo{@literal <hyeongseok.heo@samsung.com>} (S-core)\r
+ */\r
+public class CreateCertificateCLI extends AbstractCLI {\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.tizen.ncli.ide.shell.AbstractCLI#execute()\r
+ */\r
+ @Override\r
+ public void execute() {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * IDE\r
+ *\r
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ */\r
+package org.tizen.ncli.ide.shell;\r
+\r
+import org.kohsuke.args4j.Option;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+/**\r
+ * @author Harry Hyeongseok Heo{@literal <hyeongseok.heo@samsung.com>} (S-core)\r
+ */\r
+public class CreateProject extends AbstractCLI {\r
+ private Logger logger = LoggerFactory.getLogger(CreateProject.class);\r
+ \r
+ @Option(name="-t" , aliases= {"--type"})\r
+ private TizenAppType appType;\r
+ \r
+ @Option(name="-n" , aliases="--name" , required=true)\r
+ private String projectName;\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.tizen.ncli.ide.shell.AbstractCLI#execute()\r
+ */\r
+ @Override\r
+ public void execute() {\r
+ logger.info("Project Name:{}",projectName);\r
+ \r
+ switch (appType) {\r
+ case NATIVE:\r
+ logger.trace("Native app is being created");\r
+ break;\r
+ case WEB:\r
+ logger.trace("Web app is being created");\r
+ break;\r
+ default:\r
+ break;\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * IDE\r
+ *\r
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ */\r
+package org.tizen.ncli.ide.shell;\r
+\r
+/**\r
+ * @author Harry Hyeongseok Heo{@literal <hyeongseok.heo@samsung.com>} (S-core)\r
+ */\r
+public class CreateSecProfileCLI extends AbstractCLI {\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.tizen.ncli.ide.shell.AbstractCLI#execute()\r
+ */\r
+ @Override\r
+ public void execute() {\r
+ // TODO Auto-generated method stub\r
+\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * IDE\r
+ *\r
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ */\r
+package org.tizen.ncli.ide.shell;\r
+\r
+/**\r
+ * @author Harry Hyeongseok Heo{@literal <hyeongseok.heo@samsung.com>} (S-core)\r
+ */\r
+public class CreateSecProfileItemCLI extends AbstractCLI {\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.tizen.ncli.ide.shell.AbstractCLI#execute()\r
+ */\r
+ @Override\r
+ public void execute() {\r
+ // TODO Auto-generated method stub\r
+\r
+ }\r
+\r
+}\r
--- /dev/null
+/**\r
+ * \r
+ */\r
+package org.tizen.ncli.ide.shell;\r
+\r
+import java.util.List;\r
+\r
+import org.kohsuke.args4j.Argument;\r
+import org.kohsuke.args4j.CmdLineException;\r
+import org.kohsuke.args4j.CmdLineParser;\r
+import org.kohsuke.args4j.spi.OptionHandler;\r
+import org.kohsuke.args4j.spi.SubCommand;\r
+import org.kohsuke.args4j.spi.SubCommandHandler;\r
+import org.kohsuke.args4j.spi.SubCommands;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+\r
+/**\r
+ * This class is entry point of Tizen New Command Line Interface. All the command\r
+ * line argument would be parsed and then proper Command class is called.\r
+ * \r
+ * @author Harry Hyeongseok Heo{@literal <hyeongseok.heo@samsung.com>} (S-core)\r
+ * \r
+ */\r
+public class Main {\r
+\r
+ private Logger log = LoggerFactory.getLogger(Main.class);\r
+\r
+ @Argument(index = 0, required = true, handler = SubCommandHandler.class, usage = "Command is needed!")\r
+ @SubCommands({ @SubCommand(name = "create", impl = CreateCLI.class),\r
+ @SubCommand(name = "build-native", impl = BuildNativeCLI.class),\r
+ @SubCommand(name = "build-web", impl = BuildWebCLI.class),\r
+ @SubCommand(name = "sign", impl = SignCLI.class),\r
+ @SubCommand(name = "cli-config", impl = ConfigCLI.class) })\r
+ private AbstractCLI tizenCLI;\r
+\r
+ /**\r
+ * @param args\r
+ */\r
+ public static void main(String[] args) {\r
+ Main tizen = new Main();\r
+ tizen.run(args);\r
+\r
+ }\r
+\r
+ private void run(String[] args) {\r
+ CmdLineParser cmdParser = new CmdLineParser(this);\r
+\r
+ log.trace("Start running Tizen CLI Main class...");\r
+ try {\r
+ //Argument parsing - make metadata from annotation.\r
+ cmdParser.parseArgument(args);\r
+ if( null != this.tizenCLI) {\r
+ this.tizenCLI.execute();\r
+ }\r
+ \r
+ } catch (CmdLineException e) {\r
+ // TODO Handle CLI exception\r
+ e.printStackTrace();\r
+ } catch (Exception e) {\r
+ // TODO: handle exception\r
+ e.printStackTrace();\r
+ }\r
+\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.tizen.ncli.ide.shell;\r
+\r
+import org.kohsuke.args4j.Option;\r
+\r
+public class SignCLI extends AbstractCLI {\r
+ \r
+\r
+ @Option(name = "--exclude" , usage="Set exclude file pattern")\r
+ private String excludePattern;\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.tizen.ncli.ide.shell.AbstractCLI#execute()\r
+ */\r
+ @Override\r
+ public void execute() {\r
+ // TODO Auto-generated method stub\r
+ \r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * IDE\r
+ *\r
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ */\r
+package org.tizen.ncli.ide.shell;\r
+\r
+/**\r
+ * @author Harry Hyeongseok Heo{@leteral <hyeongseok.heo@samsung.com>} (S-core)\r
+ */\r
+public enum TizenAppType {\r
+ NATIVE,\r
+ WEB,\r
+ Hybrid\r
+}\r
--- /dev/null
+/*\r
+ * IDE\r
+ *\r
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ */\r
+package org.tizen.ncli.ide.subcommands;\r
+\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.tizen.common.config.Preference;\r
+import org.tizen.common.config.provider.EnvironmentProvider;\r
+import org.tizen.common.config.provider.SystemPropertiesProvider;\r
+import org.tizen.ncli.ide.CLIConstant;\r
+import org.tizen.ncli.ide.core.config.NCLIConfigLoader;\r
+import org.tizen.ncli.ide.core.config.TizenCLIConfigProvider;\r
+import org.tizen.ncli.ide.exec.NewCommandLineExecutor;\r
+\r
+\r
+/**\r
+ * This class provides common environment to other SubCommand.\r
+ * \r
+ * @author Harry Hyeongseok Heo{@literal <hyeongseok.heo@samsung.com>} (S-core)\r
+ */\r
+abstract public class AbstractSubCommand<T> {\r
+ protected final Logger logger = LoggerFactory.getLogger( getClass() );\r
+ \r
+ \r
+ /**\r
+ * This method is called by CLI entry class.<p>\r
+ * And then call <code>call()</code> method. \r
+ * \r
+ * @return T\r
+ * @throws Exception\r
+ */\r
+ public T runCommand() {\r
+ initializeConfig();\r
+ \r
+ T ret = call();\r
+ \r
+ return ret;\r
+ }\r
+\r
+ /**\r
+ * \r
+ */\r
+ private void initializeConfig() {\r
+ Preference.register( "OS", new EnvironmentProvider() );\r
+ Preference.register( "JVM", new SystemPropertiesProvider() );\r
+ Preference.register(CLIConstant.TIZEN_CLI_GLOBAL_KEY, new TizenCLIConfigProvider(NCLIConfigLoader.loadGlobalConf()));\r
+ Preference.register(CLIConstant.TIZEN_CLI_LOCAL_KEY, new TizenCLIConfigProvider(NCLIConfigLoader.loadLocalConf()));\r
+ }\r
+ \r
+ /**\r
+ * Execute command logic \r
+ * <p>This method should be called only by {@link #runCommand()}<br>\r
+ * <b>Do not call this directly</b>\r
+ * \r
+ */\r
+ protected abstract T call();\r
+\r
+}\r
--- /dev/null
+/*\r
+ * IDE\r
+ *\r
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ */\r
+package org.tizen.ncli.ide.subcommands;\r
+\r
+import java.io.File;\r
+import java.io.FileNotFoundException;\r
+import java.io.FileOutputStream;\r
+import java.io.IOException;\r
+import java.io.OutputStream;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+import java.util.Properties;\r
+import java.util.Set;\r
+\r
+import org.tizen.common.util.IOUtil;\r
+import org.tizen.ncli.ide.config.CLIConfig;\r
+import org.tizen.ncli.ide.core.config.NCLIConfigLoader;\r
+\r
+/**\r
+ * This class is for 'cli-config' command processing.\r
+ * \r
+ * @author Harry Hyeongseok Heo{@literal <hyeongseok.heo@samsung.com>} (S-core)\r
+ */\r
+public class ConfigCLICommand extends AbstractSubCommand<CLIConfig>{\r
+ private boolean list = false;\r
+ private boolean global = false;\r
+ private Map<String, String> properties = new HashMap<String, String>();\r
+\r
+ /**\r
+ * @param key\r
+ * @param value\r
+ */\r
+ public void setConfig(String key, String value) {\r
+ this.properties.put(key, value);\r
+ }\r
+\r
+ /**\r
+ * @param list\r
+ */\r
+ public void setList(boolean list) {\r
+ this.list = list;\r
+ }\r
+\r
+ /**\r
+ * @param global\r
+ */\r
+ public void setGlobal(boolean global) {\r
+ this.global = global;\r
+ }\r
+\r
+ /**\r
+ * @param properties\r
+ */\r
+ public void setKeyValue(Map<String, String> properties) {\r
+ this.properties = properties;\r
+ \r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.tizen.ncli.ide.subcommands.AbstractSubCommand#call()\r
+ */\r
+ @Override\r
+ public CLIConfig call() {\r
+ CLIConfig cliConfig = new CLIConfig();\r
+ if(list) {\r
+ return cliConfig;\r
+ }else if(global){\r
+ //global config setting\r
+ logger.trace("global config set call() - {}",properties);\r
+ \r
+ File file = NCLIConfigLoader.getGlobalConfigFile();\r
+ //Write global config file\r
+ Properties load = NCLIConfigLoader.loadGlobalConf();;\r
+ writeProperties2File(file, load);\r
+ }else {\r
+ //local config setting\r
+ logger.trace("local config set call() - {}",properties);\r
+ \r
+ File file = NCLIConfigLoader.getLocalConfigFile();\r
+ //Write local config file\r
+ Properties load = NCLIConfigLoader.loadLocalConf();;\r
+ writeProperties2File(file, load);\r
+ }\r
+ \r
+ return cliConfig;\r
+ }\r
+\r
+ private void writeProperties2File(File file, Properties load) {\r
+ Set<String> keySet = this.properties.keySet();\r
+ for (String key : keySet) {\r
+ String value = properties.get(key);\r
+ load.setProperty(key, value);\r
+ \r
+ logger.trace("key :{}",key);\r
+ logger.trace("value:{}",value);\r
+ }\r
+ OutputStream ous = null;\r
+ try {\r
+ ous = new FileOutputStream(file); \r
+ load.store(ous, "This is generated by Tizen CLI!");\r
+ } catch (FileNotFoundException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } catch (IOException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } finally {\r
+ IOUtil.tryClose(ous);\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+security.store.path=default\r
--- /dev/null
+package org.tizen.ncli.ide.shell.test;\r
+\r
+import java.io.IOException;\r
+import java.io.OutputStream;\r
+import java.util.Locale;\r
+\r
+import static org.junit.Assert.*;\r
+import org.junit.After;\r
+import org.junit.Before;\r
+\r
+import org.kohsuke.args4j.CmdLineParser;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+\r
+\r
+/**\r
+ * Base class for Args4J Tests.\r
+ * It instantiates the test object, the CmdLineParser for\r
+ * that test object and provides a String array for passing\r
+ * to the parser.\r
+ *\r
+ * @author Jan Materne\r
+ */\r
+public abstract class Args4JTestBase<T>{\r
+\r
+ CmdLineParser parser;\r
+ String[] args;\r
+ T testObject;\r
+ Logger log = LoggerFactory.getLogger(getClass());\r
+ \r
+ private Locale defaultLocale;\r
+\r
+ /**\r
+ * Specifies which concrete object to return as test object.\r
+ * @return the test object\r
+ */\r
+ public abstract T getTestObject();\r
+ \r
+ /**\r
+ * Setter for args in a vararg manner.\r
+ * @param args\r
+ */\r
+ public void setArgs(String... args) {\r
+ this.args = args;\r
+ }\r
+ \r
+ /**\r
+ * Returns the Locale to use for the tests.\r
+ * Defaults to use the US-Locale but should be overwritten by classes\r
+ * which tests I18N. \r
+ */ \r
+ public Locale getLocale() {\r
+ return Locale.US;\r
+ }\r
+\r
+ /**\r
+ * Initializes the testObject and the parser for that object.\r
+ * @see junit.framework.TestCase#setUp()\r
+ */\r
+ @Before\r
+ public void setUp() throws Exception {\r
+ defaultLocale = Locale.getDefault();\r
+ Locale.setDefault(getLocale());\r
+ testObject = getTestObject();\r
+ parser = createParser();\r
+ }\r
+\r
+ protected CmdLineParser createParser() {\r
+ return new CmdLineParser(testObject);\r
+ }\r
+\r
+ /**\r
+ * Restores the environment, namely the default Locale.\r
+ */ \r
+ @After\r
+ public void tearDown() throws Exception {\r
+ Locale.setDefault(defaultLocale);\r
+ }\r
+\r
+ /**\r
+ * Checks the number of lines of the parsers usage message.\r
+ * @param expectedLength\r
+ * @see TestCase#assertEquals(String, int, int)\r
+ * @see Args4JTestBase#getUsageMessage()\r
+ */\r
+ public void assertUsageLength(int expectedLength) {\r
+ assertEquals("Wrong amount of lines in usage message", expectedLength, getUsageMessage().length);\r
+ }\r
+ \r
+ /**\r
+ * Asserts that a given text is part of the usage message.\r
+ * @param message Error message if the text is not found.\r
+ * @param containingText Text to search for.\r
+ */\r
+ public void assertUsageContains(String message, String containingText) {\r
+ boolean contains = false;\r
+ for (String line : getUsageMessage()) {\r
+ if (line.contains(containingText)) {\r
+ contains = true;\r
+ break;\r
+ }\r
+ }\r
+ if (!contains) {\r
+ throw new AssertionError(message);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Extracts the usage message from the parser as String array.\r
+ * @return the usage message\r
+ * @see CmdLineParser#printUsage(OutputStream)\r
+ */\r
+ public String[] getUsageMessage() {\r
+ Stream2String s2s = new Stream2String();\r
+ parser.printUsage(s2s);\r
+ return s2s.getString().split(System.getProperty("line.separator"));\r
+ }\r
+\r
+ /**\r
+ * Utility class for capturing an OutputStream into a String.\r
+ * @author Jan Materne\r
+ */\r
+ private class Stream2String extends OutputStream {\r
+ private StringBuffer sb = new StringBuffer();\r
+\r
+ @Override\r
+ public void write(int b) throws IOException {\r
+ sb.append((char)b);\r
+ }\r
+\r
+ public String getString() {\r
+ return sb.toString();\r
+ }\r
+ }\r
+\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * IDE\r
+ *\r
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ */\r
+package org.tizen.ncli.ide.shell.test;\r
+\r
+import static org.junit.Assert.*;\r
+import org.junit.Test;\r
+import org.kohsuke.args4j.CmdLineException;\r
+import org.tizen.ncli.ide.shell.ConfigCLI;\r
+\r
+/**\r
+ * @author Harry Hyeongseok Heo{@literal <hyeongseok.heo@samsung.com>} (S-core)\r
+ */\r
+public class ConfigCLITest extends Args4JTestBase<ConfigCLI>{\r
+\r
+ @Test\r
+ public void test_wrong_option() throws Exception {\r
+ String [] wrongOptions = {"-ggg"};\r
+ try {\r
+ parser.parseArgument(wrongOptions);\r
+ } catch (CmdLineException e) {\r
+ assertNotNull(e);\r
+ log.error(e.toString());\r
+ assertTrue(e.toString().contains("is not a valid option"));\r
+ }\r
+ }\r
+ \r
+ \r
+ /**\r
+ * Test method for {@link org.tizen.ncli.ide.shell.ConfigCLI#execute()}.\r
+ */\r
+ @Test\r
+ public void test_list_Execute() throws Exception{\r
+ String [] args = {"-l"};\r
+ \r
+ try {\r
+ parser.parseArgument(args);\r
+ } catch (CmdLineException e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ throw new Exception();\r
+ }\r
+ String[] usageMessage = getUsageMessage();\r
+ \r
+ for (String usageMsg : usageMessage) {\r
+ log.debug("Usage:{}" , usageMsg);\r
+ \r
+ }\r
+ testObject.execute();\r
+ \r
+ }\r
+\r
+\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.tizen.ncli.ide.shell.test.Args4JTestBase#getTestObject()\r
+ */\r
+ @Override\r
+ public ConfigCLI getTestObject() {\r
+ // TODO Auto-generated method stub\r
+ return new ConfigCLI();\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * IDE\r
+ *\r
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ */\r
+package org.tizen.ncli.ide.test;\r
+\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+import java.util.Properties;\r
+\r
+import org.junit.BeforeClass;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.tizen.common.util.IOUtil;\r
+\r
+/**\r
+ * @author Harry Hyeongseok Heo{@literal <hyeongseok.heo@samsung.com>} (S-core)\r
+ */\r
+public class CommonCLISubCommandTest {\r
+\r
+ protected static Logger log = LoggerFactory.getLogger(CommonCLISubCommandTest.class);\r
+ protected static Properties testGlobalProp = new Properties();\r
+ protected static Properties testLocalProp = new Properties();\r
+\r
+ @BeforeClass\r
+ public static void prepare_once() {\r
+ InputStream configStream = null;\r
+ try {\r
+ configStream = loadTestGlobalConfig();\r
+ testGlobalProp.load(configStream);\r
+ configStream = loadTestLocalConfig();\r
+ testLocalProp.load(configStream);\r
+ } catch (IOException e) {\r
+ log.error("Load test config failed!");\r
+ e.printStackTrace();\r
+ } finally {\r
+ IOUtil.tryClose(configStream);\r
+ }\r
+ }\r
+\r
+ protected static InputStream loadTestGlobalConfig() {\r
+ final ClassLoader classLoader = CommonCLISubCommandTest.class.getClassLoader();\r
+ final String testFilePath = CommonCLISubCommandTest.class.getPackage().getName().replace(".", "/")+"/tizen-cli-config-global";\r
+ InputStream configStream = null;\r
+ configStream = classLoader.getResourceAsStream(testFilePath);\r
+ return configStream;\r
+ }\r
+ \r
+ protected static InputStream loadTestLocalConfig() {\r
+ final ClassLoader classLoader = CommonCLISubCommandTest.class.getClassLoader();\r
+ final String testFilePath = CommonCLISubCommandTest.class.getPackage().getName().replace(".", "/")+"/tizen-cli-config-local";\r
+ InputStream configStream = null;\r
+ configStream = classLoader.getResourceAsStream(testFilePath);\r
+ return configStream;\r
+ }\r
+\r
+ /**\r
+ * \r
+ */\r
+ public CommonCLISubCommandTest() {\r
+ super();\r
+ }\r
+\r
+}
\ No newline at end of file
--- /dev/null
+/**\r
+ * \r
+ */\r
+package org.tizen.ncli.ide.test;\r
+\r
+import static org.junit.Assert.*;\r
+import static org.powermock.api.mockito.PowerMockito.doAnswer;\r
+import static org.powermock.api.mockito.PowerMockito.spy;\r
+\r
+import java.io.InputStream;\r
+import java.util.Collection;\r
+import java.util.Collections;\r
+import java.util.HashSet;\r
+import java.util.Properties;\r
+\r
+import org.hamcrest.core.Is;\r
+import org.junit.Test;\r
+import org.junit.runner.RunWith;\r
+import org.mockito.invocation.InvocationOnMock;\r
+import org.mockito.stubbing.Answer;\r
+import org.powermock.core.classloader.annotations.PowerMockIgnore;\r
+import org.powermock.core.classloader.annotations.PrepareForTest;\r
+import org.powermock.modules.junit4.PowerMockRunner;\r
+import org.tizen.common.config.Preference;\r
+import org.tizen.common.config.provider.EnvironmentProvider;\r
+import org.tizen.common.config.provider.SystemPropertiesProvider;\r
+import org.tizen.ncli.ide.config.CLIConfig;\r
+import org.tizen.ncli.ide.core.config.TizenCLIConfigProvider;\r
+import org.tizen.ncli.ide.subcommands.ConfigCLICommand;\r
+\r
+/**\r
+ * @author Harry Hyeongseok Heo{@literal <hyeongseok.heo@samsung.com>} (S-core)\r
+ * \r
+ */\r
+@PowerMockIgnore({ "org.apache.log4j.*", "org.slf4j.Logger" })\r
+@RunWith(PowerMockRunner.class)\r
+@PrepareForTest(TizenCLIConfigProvider.class)\r
+public class ConfigCommandTest extends CommonCLISubCommandTest{\r
+\r
+ @Test\r
+ public void test_listConfig() throws Exception {\r
+\r
+ final TizenCLIConfigProvider globalProvider = new TizenCLIConfigProvider(testGlobalProp);\r
+ final TizenCLIConfigProvider localProvider = new TizenCLIConfigProvider(testLocalProp);\r
+\r
+ ConfigCLICommand configCmd = spy(new ConfigCLICommand());\r
+\r
+ doAnswer(new Answer<Object>() {\r
+\r
+ @Override\r
+ public Object answer(InvocationOnMock invocation) throws Throwable {\r
+ Preference.register("OS", new EnvironmentProvider());\r
+ Preference.register("JVM", new SystemPropertiesProvider());\r
+ Preference.register("TIZEN.CLI.GLOBAL", globalProvider);\r
+ Preference.register("TIZEN.CLI.LOCAL", localProvider);\r
+ return "run command called";\r
+ }\r
+\r
+ }).when(configCmd, "runCommand");\r
+\r
+ assertEquals("run command called", configCmd.runCommand());\r
+ \r
+ configCmd.setList(true);\r
+ \r
+ CLIConfig cliConfig = configCmd.call();\r
+ assertNotNull(cliConfig);\r
+ \r
+ Collection<String> expectedGlobalKeys = new HashSet<String>();\r
+ expectedGlobalKeys.add("global.key1");\r
+ expectedGlobalKeys.add("global.key2");\r
+ expectedGlobalKeys.add("global.key1.subkey1");\r
+ assertTrue(cliConfig.getGlobalKeys().containsAll(expectedGlobalKeys));\r
+ \r
+ Collection<String> expectedLocalKeys = new HashSet<String>();\r
+ expectedLocalKeys.add("global.key1");\r
+ expectedLocalKeys.add("local.key2");\r
+ expectedLocalKeys.add("local.key1.subkey1"); \r
+ \r
+ assertTrue(cliConfig.getLocalKeys().containsAll(expectedLocalKeys));\r
+ \r
+ }\r
+ \r
+ @Test\r
+ public void test_setLocalConfig() throws Exception {\r
+ final TizenCLIConfigProvider globalProvider = new TizenCLIConfigProvider(testGlobalProp);\r
+ final TizenCLIConfigProvider localProvider = new TizenCLIConfigProvider(testLocalProp);\r
+\r
+ ConfigCLICommand configCmd = spy(new ConfigCLICommand());\r
+\r
+ doAnswer(new Answer<Object>() {\r
+\r
+ @Override\r
+ public Object answer(InvocationOnMock invocation) throws Throwable {\r
+ Preference.register("OS", new EnvironmentProvider());\r
+ Preference.register("JVM", new SystemPropertiesProvider());\r
+ Preference.register("TIZEN.CLI.GLOBAL", globalProvider);\r
+ Preference.register("TIZEN.CLI.LOCAL", localProvider);\r
+ return "run command called";\r
+ }\r
+\r
+ }).when(configCmd, "runCommand");\r
+ \r
+ configCmd.setConfig("local.key.test", "this is LOCAL test value");\r
+ configCmd.call();\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * IDE\r
+ *\r
+ * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact:\r
+ * Hyeongseok Heo <hyeongseok.heo@samsung.com>\r
+ * Kangho Kim <kh5325.kim@samsung.com>\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ */\r
+package org.tizen.ncli.ide.test;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+import static org.junit.Assert.assertTrue;\r
+\r
+import java.util.Collection;\r
+import java.util.Collections;\r
+import java.util.HashSet;\r
+\r
+import org.junit.Test;\r
+import org.tizen.ncli.ide.core.config.TizenCLIConfigProvider;\r
+\r
+/**\r
+ * @author Harry Hyeongseok Heo{@literal <hyeongseok.heo@samsung.com>} (S-core)\r
+ */\r
+public class TizenCLIConfigProviderTest extends CommonCLISubCommandTest {\r
+ @Test\r
+ public void test_getKey() throws Exception {\r
+ log.trace("test_getKey");\r
+ HashSet<String> keySet = new HashSet<String>();\r
+ keySet.add("global.key1");\r
+ keySet.add("global.key1");\r
+ keySet.add("global.key1.subkey1");\r
+ \r
+ Collection<String> expectKeys = Collections.unmodifiableCollection(keySet);\r
+ \r
+ TizenCLIConfigProvider cliProvider = new TizenCLIConfigProvider(testGlobalProp); \r
+ Collection<String> keys = cliProvider.keys();\r
+ \r
+ assertTrue(keys.containsAll(expectKeys));\r
+ }\r
+ \r
+ @Test\r
+ public void test_getValue() {\r
+ TizenCLIConfigProvider cliProvider = new TizenCLIConfigProvider(testGlobalProp);\r
+ assertEquals("This is global value1", cliProvider.get("global.key1"));\r
+ assertEquals("This is global value2", cliProvider.get("global.key2"));\r
+ assertEquals("This is global subkey value1", cliProvider.get("global.key1.subkey1"));\r
+ }\r
+\r
+}\r
--- /dev/null
+global.key1=This is global value1\r
+global.key2=This is global value2\r
+global.key1.subkey1=This is global subkey value1\r
--- /dev/null
+global.key1=This is local value1\r
+local.key2=This is global value2\r
+local.key1.subkey1=This is local subkey value1\r
--- /dev/null
+\r
+\r
+command=java -cp
\ No newline at end of file
--- /dev/null
+#!/bin/sh\r
+cmd=\r
+for a in "$@"\r
+do\r
+ case "$a" in\r
+ -*) continue ;;\r
+ *) cmd=$a; break; ;;\r
+ esac\r
+done\r
--- /dev/null
+1. tizen.sh \r
+2. Main - entry point of Tizen new cli\r
+3. Command handler\r
+4. Sub command handler
\ No newline at end of file