--- /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 (%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.gen.Main
+
+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%
+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
+/*
+* Web IDE - Command Line Interface
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* GyeongSeok Seo <gyeongseok.seo@samsung.com>
+* BonYong Lee <bonyong.lee@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.cli.exec.gen;
+
+import static org.junit.Assert.*;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.PosixParser;
+import org.apache.commons.cli.UnrecognizedOptionException;
+import org.junit.Test;
+import org.tizen.cli.exec.AbstractMainTest;
+import org.tizen.common.core.command.Executor;
+
+/**
+ * MainTest
+ *
+ * Test case for {@link Main}
+ *
+ * @author GyeongSeok Seo{@literal <gyeongseok.seo@samsung.com>} (S-Core)
+ * @author BonYong Lee{@literal <bonyong.lee@samsung.com>} (S-Core)
+ *
+ * @see Main
+ */
+public class
+MainTest
+extends AbstractMainTest
+{
+ /**
+ * Test {@link Main#getOptions()}
+ *
+ * @throws Exception in case of failure in test
+ *
+ * @see Main#getOptions()
+ */
+ @Test
+ public void
+ test_getOptions()
+ throws Exception
+ {
+ Main testClass = new Main();
+ final Options opts = testClass.getOptions();
+ final PosixParser parser = new PosixParser();
+
+ parser.parse( opts, new String[] {
+ "-help", "-quiet", "-name", "myproject", "-path", "/home/myproject"
+ } );
+
+ parser.parse( opts, new String[] {
+ "--help", "--quiet", "--name", "myproject", "--path", "/home/myproject"
+ } );
+
+ parser.parse( opts, new String[] {
+ "-h", "-q", "-n", "myproject", "-p", "/home/myproject"
+ } );
+
+ try {
+ parser.parse( opts, new String[] {
+ "-verbose", "-quiet"
+ } );
+ fail();
+ } catch ( final UnrecognizedOptionException e ) {
+ }
+
+ {
+ final CommandLine cmd = parser.parse( opts, new String[] {
+ "--log=trace", "--name", "myproject", "--path", "/home/myproject"
+ } );
+ final String[] args1 = cmd.getOptionValues( Main.OPT_NAME );
+ assertEquals( 1, args1.length );
+ assertEquals( "myproject", args1[0] );
+ final String[] shortArgs1 = cmd.getOptionValues( "n" );
+ assertEquals( 1, shortArgs1.length );
+ assertEquals( "myproject", shortArgs1[0] );
+
+ final String[] args2 = cmd.getOptionValues( Main.OPT_PATH );
+ assertEquals( 1, args2.length );
+ assertEquals( "/home/myproject", args2[0] );
+ final String[] shortArgs2 = cmd.getOptionValues( "p" );
+ assertEquals( 1, shortArgs2.length );
+ assertEquals( "/home/myproject", shortArgs2[0] );
+ }
+
+ {
+ final CommandLine cmd = parser.parse( opts, new String[] {
+ "--log=debug", "-n", "myproject", "-p", "/home/myproject"
+ } );
+ final String[] args1 = cmd.getOptionValues( Main.OPT_NAME );
+ assertNotNull( args1 );
+ final String[] args2 = cmd.getOptionValues( Main.OPT_PATH );
+ assertNotNull( args2 );
+ }
+ }
+
+ /**
+ * Test {@link Main#run(String...)}
+ *
+ * @throws Exception in case of failure in test
+ *
+ * @see Main#run(String...)
+ */
+ @Test
+ public
+ void
+ test_run()
+ throws Exception
+ {
+ final AtomicBoolean result = new AtomicBoolean( false );
+
+ final Main testClass = new Main()
+ {
+ protected Executor getExecutor() {
+ return MainTest.this.executor;
+ }
+
+ protected void execute( final CommandLine cmdLine ) throws Exception {
+ result.set( true );
+ }
+ };
+
+ testClass.run( "-n", "myproject", "-p", "/home/myproject" );
+ assertTrue( result.get() );
+ }
+}