--- /dev/null
+#!/bin/sh
+
+export MAIN=org.tizen.cli.exec.template.ClientMain
+
+SCRIPT="$0"
+
+while [ -h "$SCRIPT" ] ; do
+ ls=`ls -ld "$SCRIPT"`
+
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ SCRIPT="$link"
+ else
+ SCRIPT=`dirname "$SCRIPT"`/"$link"
+ fi
+done
+
+export DIR_BIN=`dirname $SCRIPT`
+export DIR_HOME=$DIR_BIN/..
+
+. $DIR_BIN/common.sh
+
+for ARG in "$@" ; do
+ ARGS="$ARGS $(escapeSpace $ARG)"
+done
+
+OPT="$OPT -Dtizen.template.realm=file://$DIR_HOME/realm/config.json"
+
+EXEC="java -cp $CLASSPATH $OPT $MAIN $ARGS"
+
+if [ -n "$OPT_TRACE" ]
+then
+ echo "Command :$EXEC"
+fi
+
+eval "$EXEC"
--- /dev/null
+@echo off
+set SCRIPT=%0
+
+:: delims is a TAB followed by a space
+set KEY=TIZEN_SDK_INSTALLED_PATH
+
+REM find sdk path
+set rkey="HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
+set rval="Local AppData"
+FOR /f "tokens=3*" %%a IN ('reg query %rkey% /v %rval%') DO (
+ set sdk_conf_path=%%b
+)
+
+REM find cli path
+FOR /f "tokens=1,2 delims==" %%i IN ('type "%sdk_conf_path%\tizen-sdk-data\tizensdkpath"') DO IF %%i==%KEY% (set SDK_PATH=%%j)
+set CLI_HOME=%SDK_PATH%\tools\ide
+
+set MAIN=org.tizen.cli.exec.template.ClientMain
+
+set OPT_TRACE=
+set OPT_LOGGING=-Dlog4j.configuration=log4j.xml
+set OPT_PRG_NAME=-Dcli.name=%SCRIPT%
+
+set READ_ARG=n
+
+FOR %%W IN ( %* ) DO ( call:parseArg %%W )
+
+set OPT=%OPT_TRACE% %OPT_LOGGING% %OPT_PRG_NAME% -Dtizen.template.realm=file://%CLI_HOME\realm/config.json
+set EXEC=java -cp %CLI_HOME%\conf -Djava.ext.dirs=%CLI_HOME%\lib %OPT% %MAIN% %*
+
+IF NOT "" == "%OPT_TRACE%" ( echo Command :%EXEC% )
+
+%EXEC%
+goto:eof
+
+:parseArg
+ IF y == %READ_ARG% goto SET_LOGGING
+
+:SECOND_STEP
+ IF %~1 == --log goto SET_READY
+ IF %~1 == -l goto SET_READY
+:END_STEP
+goto:eof
+
+:SET_LOGGING
+ set OPT_LOGGING=-Dlog4j.configuration=log4j-%~1.xml
+ IF %~1 == trace set OPT_TRACE=-Dlog4j.debug=true
+ set READ_ARG=n
+
+ goto SECOND_STEP
+
+:SET_READY
+ set READ_ARG=y
+ goto END_STEP
+
--- /dev/null
+/*\r
+ * Web IDE - Command Line Interface\r
+ *\r
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: \r
+ * BonYong Lee <bonyong.lee@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
+ */\r
+package org.tizen.cli.exec.template;\r
+\r
+import static org.apache.commons.cli.OptionBuilder.withLongOpt;\r
+import static org.tizen.common.util.ArrayUtil.isEmpty;\r
+import static org.tizen.common.util.StringUtil.isEmpty;\r
+import static org.tizen.common.util.StringUtil.nvl;\r
+\r
+import java.net.URL;\r
+\r
+import org.apache.commons.cli.CommandLine;\r
+import org.apache.commons.cli.Options;\r
+import org.tizen.cli.command.CreateTemplate;\r
+import org.tizen.cli.command.PluginConstants;\r
+import org.tizen.cli.command.SearchTemplate;\r
+import org.tizen.cli.exec.AbstractLauncher;\r
+import org.tizen.cli.exec.ILaunchOptions;\r
+import org.tizen.common.config.Preference;\r
+import org.tizen.common.verrari.Realm;\r
+import org.tizen.common.verrari.RealmFactory;\r
+\r
+/**\r
+ * Command Line Interface to create from template\r
+ * \r
+ * @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)\r
+ */\r
+public class\r
+ClientMain\r
+extends AbstractLauncher\r
+implements ILaunchOptions\r
+{\r
+ protected static final String OPT_REALM = "realm";\r
+ \r
+ protected static final String DESC_REALM = "Specify realm for template";\r
+ \r
+ protected static final String OPT_SEARCH = "search";\r
+ \r
+ protected static final String DESC_SEARCH = "Search template with keyword";\r
+ \r
+ \r
+ /**\r
+ * entry point\r
+ * \r
+ * @param args input argument\r
+ * \r
+ * @throws Exception If unhandled exception\r
+ */\r
+ public static\r
+ void\r
+ main(\r
+ final String[] args\r
+ )\r
+ throws Exception\r
+ {\r
+ new ClientMain().run( args );\r
+ }\r
+ \r
+ /* (non-Javadoc)\r
+ * @see org.tizen.cli.exec.AbstractLauncher#getOptions()\r
+ */\r
+ @SuppressWarnings("static-access")\r
+ @Override\r
+ protected Options getOptions()\r
+ {\r
+ final Options ret = super.getOptions();\r
+ \r
+ ret.addOption( withLongOpt( OPT_REALM ).withDescription( DESC_REALM ).hasArg().create( OPT_REALM.substring( 0, 1 ) ) );\r
+ ret.addOption( withLongOpt( OPT_SEARCH ).withDescription( DESC_SEARCH ).hasArg().create( OPT_SEARCH.substring( 0, 1 ) ) );\r
+ \r
+ return ret;\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.tizen.cli.exec.AbstractLauncher#execute(org.apache.commons.cli.CommandLine)\r
+ */\r
+ @Override\r
+ protected\r
+ void\r
+ execute(\r
+ final CommandLine cmdLine\r
+ )\r
+ throws Exception\r
+ {\r
+ final String urlStr = nvl( Preference.getValue( "tizen.template.realm", null ) );\r
+ logger.info( "Realm url :{}", urlStr );\r
+ if ( isEmpty( urlStr ) )\r
+ {\r
+ getPrompter().error( "No realm!! Specify realm with --realm option" );\r
+ return ;\r
+ }\r
+ \r
+ final URL url = new URL( urlStr );\r
+ Realm realm = null;\r
+ try\r
+ {\r
+ realm = RealmFactory.getInstance().create( url );\r
+ }\r
+ catch ( final Throwable e )\r
+ {\r
+ getPrompter().error( "Invalid realm!! Check realm and its contents :" + urlStr );\r
+ return ;\r
+ }\r
+ \r
+ getExecutionContext().setValue( PluginConstants.REALM, realm );\r
+ \r
+ if ( cmdLine.hasOption( OPT_SEARCH ) )\r
+ {\r
+ \r
+ if ( !isEmpty( cmdLine.getArgs() ) )\r
+ {\r
+ printHelp();\r
+ return ;\r
+ }\r
+ final SearchTemplate command = new SearchTemplate();\r
+ command.process( getExecutionContext(), new String[] { cmdLine.getOptionValue( OPT_SEARCH ) } );\r
+ \r
+ }\r
+ else\r
+ {\r
+ if ( isEmpty( cmdLine.getArgs() ) )\r
+ {\r
+ printHelp();\r
+ return ;\r
+ }\r
+ \r
+ final CreateTemplate command = new CreateTemplate();\r
+ command.process( getExecutionContext(), cmdLine.getArgs() );\r
+ }\r
+ \r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+* Web IDE - Command Line Interface\r
+*\r
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+*\r
+* Contact: \r
+* BonYong Lee <bonyong.lee@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
+*/\r
+package org.tizen.cli.exec.template;\r
+\r
+import static org.junit.Assert.assertNotNull;\r
+import static org.mockito.Mockito.mock;\r
+\r
+import org.apache.commons.cli.CommandLine;\r
+import org.apache.commons.cli.Options;\r
+import org.apache.commons.cli.PosixParser;\r
+import org.junit.Test;\r
+import org.tizen.cli.exec.CommandLineExecutor;\r
+import org.tizen.cli.exec.sign.Main;\r
+import org.tizen.common.core.command.Executor;\r
+import org.tizen.common.core.command.Prompter;\r
+\r
+/**\r
+ * ClientMainTest\r
+ *\r
+ * Test case for {@link ClientMain}\r
+ * \r
+ * @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)\r
+ * \r
+ * @see ClientMain\r
+ */\r
+public class\r
+ClientMainTest\r
+{\r
+\r
+ /**\r
+ * Test {@link ClientMain#getOptions()}\r
+ * \r
+ * @throws Exception in case of failure in test\r
+ * \r
+ * @see ClientMain#getOptions()}\r
+ */\r
+ @Test\r
+ public\r
+ void\r
+ test_getOptions()\r
+ {\r
+ final ClientMain target = new ClientMain();\r
+ final Options opts = target.getOptions();\r
+ assertNotNull( opts );\r
+ }\r
+ \r
+ /**\r
+ * Test {@link ClientMain#run(String...)}\r
+ * \r
+ * @throws Exception in case of failure in test\r
+ * \r
+ * @see ClientMain#run(String...)}\r
+ */\r
+ @Test\r
+ public\r
+ void\r
+ test_run()\r
+ throws Exception\r
+ {\r
+ final Prompter prompterMock = mock( Prompter.class );\r
+ final Executor executor2 = new CommandLineExecutor( prompterMock );\r
+ final ClientMain target = new ClientMain() {\r
+ @Override\r
+ protected Executor getExecutor()\r
+ {\r
+ return executor2;\r
+ }\r
+ \r
+ };\r
+ final PosixParser parser = new PosixParser();\r
+ final CommandLine cmd = parser.parse( target.getOptions(), new String[] {} );\r
+ target.execute( cmd );\r
+ }\r
+\r
+}\r