{
return getExecutionContext().getPrompter();
}
-
+
+ /**
+ * Terminates the currently running command line interface.<p>
+ * The argument serves as a status code<br>
+ * by convention, a nonzero status code indicates abnormal termination.<br>
+ * This method calls the System.exit method.
+ *
+ * @param status exit status.
+ */
+ protected
+ void
+ exit(int status)
+ {
+ System.exit( status );
+ }
+
/**
* Execute command
*
+++ /dev/null
-package org.tizen.cli.exec;\r
-\r
-public interface ILaunchOptions\r
-{\r
- \r
- /**\r
- * <p>\r
- * Description for target widget id\r
- * \r
- * This is printed out in usage\r
- * </p>\r
- * \r
- * @see #OPT_WIDGETID\r
- */\r
- String DESC_WIDGETID = "Command is performed of running widget kill in target, widget id is user written id in config.xml";\r
-\r
- /**\r
- * <p>\r
- * Option for target widget file\r
- * </p>\r
- */\r
- String OPT_WIDGETFILE = "widget";\r
-\r
- /**\r
- * <p>\r
- * Description for target widget file\r
- * \r
- * This is printed out in usage\r
- * </p>\r
- * \r
- * @see #OPT_WIDGETFILE\r
- */\r
- String DESC_WIDGETFILE = "Command is performed of widget file install in target";\r
-\r
- /**\r
- * <p>\r
- * Option for target widget id\r
- * </p>\r
- */\r
- String OPT_WIDGETID = "id";\r
-\r
- /**\r
- * <p>\r
- * Option for project name\r
- * </p>\r
- */\r
- String OPT_NAME = "name";\r
-\r
- /**\r
- * <p>\r
- * Description for project name\r
- * \r
- * This is printed out in usage\r
- * </p>\r
- * \r
- * @see #OPT_WIDGETFILE\r
- */\r
- String DESC_NAME = "generation project name";\r
-\r
- /**\r
- * <p>\r
- * Option for project name\r
- * </p>\r
- */\r
- String OPT_PATH = "path";\r
-\r
- /**\r
- * <p>\r
- * Description for project name\r
- * \r
- * This is printed out in usage\r
- * </p>\r
- * \r
- * @see #OPT_WIDGETFILE\r
- */\r
- String DESC_PATH = "generation project path";\r
-\r
- \r
- /**\r
- * <p>\r
- * Option for include file pattern\r
- * </p>\r
- */\r
- String OPT_INCLUDE = "include";\r
- \r
- /**\r
- * <p>\r
- * Description for include file pattern option\r
- * \r
- * It is printed out in usage\r
- * </p>\r
- */\r
- String DESC_INCLUDE = "file name pattern to include";\r
- \r
- /**\r
- * <p>\r
- * Option for exclude file pattern\r
- * </p>\r
- */\r
- String OPT_EXCLUDE = "exclude";\r
- \r
- /**\r
- * <p>\r
- * Description for exclude file pattern option\r
- * \r
- * It is printed out in usage\r
- * </p>\r
- */\r
- String DESC_EXCLUDE = "file name pattern to exclude";\r
- \r
- /**\r
- * <p>\r
- * Option for no check of validation\r
- * </p>\r
- */\r
- String OPT_NOCHECK = "nocheck";\r
- \r
- /**\r
- * <p>\r
- * Description for no check option\r
- * \r
- * It is printed out in usage\r
- * </p>\r
- */\r
- String DESC_NOCHECK = "skip validation check";\r
- \r
- /**\r
- * <p>\r
- * Option for over-writing of output file\r
- * </p>\r
- */\r
- String OPT_OVERWRITE = "overwrite";\r
- \r
- /**\r
- * <p>\r
- * Description for overwrite option\r
- * \r
- * It is printed out in usage\r
- * </p>\r
- */\r
- String DESC_OVERWRITE = "overwrite output file if it exists";\r
-}\r
--- /dev/null
+package org.tizen.cli.exec;
+
+public class LaunchOptionConstants
+{
+ private LaunchOptionConstants() {}
+
+ /**
+ * <p>
+ *Description for failed operation
+ *
+ * This is printed when widget ID is empty
+ * </p>
+ */
+ public static final String DESC_FAILED_CANNOT_FIND_WIDGET_ID = "can't find application ID";
+
+ /**
+ * <p>
+ *Description for failed operation
+ *
+ * This is printed when device is not connected
+ * </p>
+ */
+ public static final String DESC_FAILED_CANNOT_FIND_CONNECTED_DEVICE = "can't find connected device";
+
+ /**
+ * <p>
+ *Description for failed operation
+ *
+ * This is printed when device is not connected
+ * </p>
+ */
+ public static final String DESC_FAILED_CANNOT_FIND_SELECTED_DEVICE = "can't find selected device";
+
+ /**
+ * <p>
+ *Description for failed operation
+ *
+ * This is printed when mode setting operation failed
+ * </p>
+ */
+ public static final String DESC_FAILED_MODE_SETTING = "development mode setting failed";
+
+
+ /**
+ * <p>
+ * Description for target widget id
+ *
+ * This is printed out in usage
+ * </p>
+ *
+ * @see #OPT_WIDGETID
+ */
+ public static final String DESC_WIDGETID = "Command is performed of running widget kill in target, widget id is user written id in config.xml";
+
+ /**
+ * <p>
+ * Option for target widget file
+ * </p>
+ */
+ public static final String OPT_WIDGETFILE = "widget";
+
+ /**
+ * <p>
+ * Description for target widget file
+ *
+ * This is printed out in usage
+ * </p>
+ *
+ * @see #OPT_WIDGETFILE
+ */
+ public static final String DESC_WIDGETFILE = "Command is performed of widget file install in target";
+
+ /**
+ * <p>
+ * Option for target widget id
+ * </p>
+ */
+ public static final String OPT_WIDGETID = "id";
+
+ /**
+ * <p>
+ * Option for project name
+ * </p>
+ */
+ public static final String OPT_NAME = "name";
+
+ /**
+ * <p>
+ * Description for project name
+ *
+ * This is printed out in usage
+ * </p>
+ *
+ * @see #OPT_WIDGETFILE
+ */
+ public static final String DESC_NAME = "generation project name";
+
+ /**
+ * <p>
+ * Option for project name
+ * </p>
+ */
+ public static final String OPT_PATH = "path";
+
+ /**
+ * <p>
+ * Description for project name
+ *
+ * This is printed out in usage
+ * </p>
+ *
+ * @see #OPT_WIDGETFILE
+ */
+ public static final String DESC_PATH = "generation project path";
+
+
+ /**
+ * <p>
+ * Option for include file pattern
+ * </p>
+ */
+ public static final String OPT_INCLUDE = "include";
+
+ /**
+ * <p>
+ * Description for include file pattern option
+ *
+ * It is printed out in usage
+ * </p>
+ */
+ public static final String DESC_INCLUDE = "file name pattern to include";
+
+ /**
+ * <p>
+ * Option for exclude file pattern
+ * </p>
+ */
+ public static final String OPT_EXCLUDE = "exclude";
+
+ /**
+ * <p>
+ * Description for exclude file pattern option
+ *
+ * It is printed out in usage
+ * </p>
+ */
+ public static final String DESC_EXCLUDE = "file name pattern to exclude";
+
+ /**
+ * <p>
+ * Option for no check of validation
+ * </p>
+ */
+ public static final String OPT_NOCHECK = "nocheck";
+
+ /**
+ * <p>
+ * Description for no check option
+ *
+ * It is printed out in usage
+ * </p>
+ */
+ public static final String DESC_NOCHECK = "skip validation check";
+
+ /**
+ * <p>
+ * Option for over-writing of output file
+ * </p>
+ */
+ public static final String OPT_OVERWRITE = "overwrite";
+
+ /**
+ * <p>
+ * Description for overwrite option
+ *
+ * It is printed out in usage
+ * </p>
+ */
+ public static final String DESC_OVERWRITE = "overwrite output file if it exists";
+}
SmartDevelopmentBridge.getBridge().terminate();
}
+ /**
+ * Terminates the currently running command line interface.<p>
+ * The argument serves as a status code, by convention, a nonzero status code indicates abnormal termination.<br>
+ * Before the exit, this method terminate SDB bridge.
+ * This method calls the System.exit method.
+ *
+ * @param status exit status.
+ */
+ @Override
+ protected void exit(int status) {
+ endSDB();
+ super.exit(status);
+ }
+
+ protected String getDeviceNotConnectedMessage() {
+ return "Device is not connected. Process is canceled.";
+ }
+ protected String getDeviceNotSelectedMessage() {
+ return "Process is stoped, please select connect device.";
+ }
+
/* (non-Javadoc)
* @see org.tizen.cli.exec.AbstractLauncher#execute(org.apache.commons.cli.CommandLine)
*/
logger.trace("check connected devices");
if ( !deviceSelector.isDeviceConnected() ) {
- prompter.notify( "Device is not connected. Process is canceled." );
- endSDB();
- return ;
+ prompter.notify( getDeviceNotConnectedMessage() );
+ exit( 1 );
}
String deviceName = cmdLine.getOptionValue( OPT_DEVICE );
if ( !StringUtil.isEmpty( deviceName ) ) {
setDevice( deviceSelector.getDevice( deviceName ) );
if ( getDevice() == null ) {
- prompter.notify( "Process is stoped, please select connect device." );
+ prompter.notify( getDeviceNotSelectedMessage() );
+ exit( 1 );
}
} else {
// user not using device select option
*/
package org.tizen.cli.exec.debug;
+import static org.tizen.cli.exec.LaunchOptionConstants.OPT_WIDGETID;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_MODE_SETTING;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_WIDGETID;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_CANNOT_FIND_WIDGET_ID;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_CANNOT_FIND_CONNECTED_DEVICE;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_CANNOT_FIND_SELECTED_DEVICE;
+
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
-import org.tizen.cli.exec.ILaunchOptions;
import org.tizen.cli.exec.WRTLauncher;
import org.tizen.common.core.command.Executor;
import org.tizen.common.core.command.Prompter;
-import org.tizen.common.core.command.sdb.PushSdbCommand;
-import org.tizen.common.file.FileHandler;
-import org.tizen.common.file.FileHandler.Attribute;
-import org.tizen.common.util.FilenameUtil;
import org.tizen.common.util.StringUtil;
import org.tizen.web.zimlaunch.cli.command.CheckInstallCommand;
import org.tizen.web.zimlaunch.cli.command.DebugCommand;
-import org.tizen.web.zimlaunch.cli.command.InstallCommand;
import org.tizen.web.zimlaunch.cli.command.KillCommand;
import org.tizen.web.zimlaunch.cli.command.ModeCommnad;
public class
Main
extends WRTLauncher
-implements ILaunchOptions
{
-
- /**
- * <p>
- * Description for target widget id
- *
- * This is printed out in usage
- * </p>
- *
- * @see #OPT_WIDGETID
- */
- protected static final String DESC_WIDGETID = "Command is performed of widget id uninstall in target, widget id is user written id in config.xml";
+ protected String FAILED_LAUNCH = "Failed to launch: ";
/**
* Entry point for cli main
super.execute( cmdLine );
final Prompter prompter = getPrompter();
- final FileHandler fileHandler = getFileHandler();
final Executor exec = getExecutor();
- // device not connect then exit
- if ( getDevice() == null ) {
- endSDB();
- return ;
- }
-
- // local widget file path control
- String inputName = cmdLine.getOptionValue( OPT_WIDGETFILE );
- logger.trace("input file name : {} ", inputName);
- if ( StringUtil.isEmpty( inputName ) ) {
- prompter.notify( "Widget file is not selected." );
- printHelp();
- endSDB();
- }
+ // get widget AppID
+ logger.trace( "application id value input check" );
String widgetId = cmdLine.getOptionValue( OPT_WIDGETID );
+ if ( StringUtil.isEmpty( widgetId ) ) {
+ prompter.error( FAILED_LAUNCH + DESC_FAILED_CANNOT_FIND_WIDGET_ID );
+ exit( 1 );
+ }
- String filePath = (String)fileHandler.get( inputName, Attribute.PATH );
- logger.trace( "local widget file path : {}", filePath );
-
- String fileName = FilenameUtil.getFilename( inputName );
- logger.trace( "local widget file name : {}", fileName );
-
- // core operation
- InstallCommand install_command = new InstallCommand();
- install_command.setWidget( fileName );
- install_command.setDevice( getDevice() );
- install_command.setTime( getTime() );
- install_command.setPrintOption( false );
- String remotePath = install_command.getRemotePath() + fileName;
- logger.trace( "remote widget file path : {}", remotePath );
-
- PushSdbCommand push_command = new PushSdbCommand( filePath, remotePath );
- push_command.setDevice( getDevice() );
-
+ // mode command
ModeCommnad mode_command = new ModeCommnad();
mode_command.setDevice( getDevice() );
mode_command.setTime( getTime() );
-
- // widget push
- logger.trace( "push command");
- exec.execute( push_command );
- if ( "failed".equals( push_command.getResult() ) ) {
- endSDB();
- }
+ mode_command.setPrintOption( false );
// widget mode
logger.trace( "mode command");
exec.execute( mode_command );
- if ( mode_command.getResult().contains( "failed" ) ) {
- endSDB();
+ if ( mode_command.getResult().contains( "Failed" ) ) {
+ prompter.error( FAILED_LAUNCH + DESC_FAILED_MODE_SETTING );
+ exit( 1 );
}
- if ( !StringUtil.isEmpty( widgetId ) ) {
- logger.trace( "same widget's pre-install check and kill process" );
- CheckInstallCommand check_install_cmd = new CheckInstallCommand( widgetId );
- check_install_cmd.setDevice( getDevice() );
- check_install_cmd.setTime( getTime() );
- check_install_cmd.setPrintOption( false );
- exec.execute( check_install_cmd );
- if ( check_install_cmd.isInstalled() ) {
- KillCommand kill_cmd = new KillCommand( widgetId );
- kill_cmd.setPrintOption( false );
- kill_cmd.setDevice( getDevice() );
- kill_cmd.setTime( getTime() );
- exec.execute( kill_cmd );
- }
+ // already run check and kill
+ logger.trace( "same widget's pre-install check and kill process" );
+ CheckInstallCommand check_install_cmd = new CheckInstallCommand( widgetId );
+ check_install_cmd.setDevice( getDevice() );
+ check_install_cmd.setTime( getTime() );
+ check_install_cmd.setPrintOption( false );
+ exec.execute( check_install_cmd );
+ if ( check_install_cmd.isInstalled() ) {
+ KillCommand kill_cmd = new KillCommand( widgetId );
+ kill_cmd.setPrintOption( false );
+ kill_cmd.setDevice( getDevice() );
+ kill_cmd.setTime( getTime() );
+ exec.execute( kill_cmd );
}
- // widget install
- logger.trace( "install command");
- exec.execute( install_command );
-
// widget debug run
DebugCommand run_command = new DebugCommand( widgetId );
run_command.setDevice( getDevice() );
run_command.setTime( getTime() );
+ run_command.setPrintOption( false );
exec.execute( run_command );
- endSDB();
+ prompter.notify( run_command.getResult() );
+ if ( run_command.getResult().contains( "failed" ) ) {
+ exit( 1 );
+ } else {
+ exit( 0 );
+ }
}
/* (non-Javadoc)
getOptions()
{
final Options opts = super.getOptions();
- opts.addOption( OptionBuilder.hasArg().isRequired().withLongOpt( OPT_WIDGETFILE ).withDescription( DESC_WIDGETFILE ).create( OPT_WIDGETFILE.substring( 0, 1 ) ) );
opts.addOption( OptionBuilder.hasArg().isRequired().withLongOpt( OPT_WIDGETID ).withDescription( DESC_WIDGETID ).create( OPT_WIDGETID.substring( 0, 1 ) ) );
return opts;
}
+
+ /* (non-Javadoc)
+ * @see org.tizen.cli.exec.WRTLauncher#getDeviceNotConnectedMessage()
+ */
+ @Override
+ protected String getDeviceNotConnectedMessage() {
+ return FAILED_LAUNCH + DESC_FAILED_CANNOT_FIND_CONNECTED_DEVICE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tizen.cli.exec.WRTLauncher#getDeviceNotSelectedMessage()
+ */
+ @Override
+ protected String getDeviceNotSelectedMessage() {
+ return FAILED_LAUNCH + DESC_FAILED_CANNOT_FIND_SELECTED_DEVICE;
+ }
}
import java.text.MessageFormat;
+import static org.tizen.cli.exec.LaunchOptionConstants.OPT_NAME;
+import static org.tizen.cli.exec.LaunchOptionConstants.OPT_PATH;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_NAME;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_PATH;
+
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.tizen.cli.exec.AbstractLauncher;
-import org.tizen.cli.exec.ILaunchOptions;
import org.tizen.common.core.command.Prompter;
import org.tizen.common.core.command.prompter.ChoiceOption;
import org.tizen.common.core.command.prompter.Option;
public class
Main
extends AbstractLauncher
-implements ILaunchOptions
{
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.tizen.cli.exec.AbstractLauncher;
-import org.tizen.cli.exec.ILaunchOptions;
import org.tizen.common.core.application.InstallPathConfig;
import org.tizen.common.core.command.Prompter;
import org.tizen.common.core.command.prompter.ChoiceOption;
import org.tizen.nativecommon.templateengine.TizenTemplateEngine.WizardMode;
import org.tizen.nativecommon.templateengine.model.TizenTemplate;
-public class NativeMain extends AbstractLauncher implements ILaunchOptions{
+public class NativeMain extends AbstractLauncher {
private static final String OPTION_PROJECTPATH = "path";
private static final String OPTION_PROJECTNAME = "name";
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
-import org.tizen.cli.exec.ILaunchOptions;
+import static org.tizen.cli.exec.LaunchOptionConstants.OPT_WIDGETFILE;
+import static org.tizen.cli.exec.LaunchOptionConstants.OPT_WIDGETID;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_WIDGETID;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_WIDGETFILE;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_CANNOT_FIND_CONNECTED_DEVICE;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_CANNOT_FIND_SELECTED_DEVICE;
+
import org.tizen.cli.exec.WRTLauncher;
import org.tizen.common.core.command.Executor;
import org.tizen.common.core.command.Prompter;
public class
Main
extends WRTLauncher
-implements ILaunchOptions
{
+ protected String FAILED_INSTALL = "Failed to install: ";
/**
* <p>
- * Description for target widget id
+ *Description for failed operation
*
- * This is printed out in usage
+ * This is printed when device is not connected
* </p>
- *
- * @see #OPT_WIDGETID
*/
- protected static final String DESC_WIDGETID = "Command is performed of running widget kill in target, widget id is user written id in config.xml";
+ String DESC_FAILED_CANNOT_FIND_SELECTED_WIDGET = "can't find selected widget file";
/**
* Entry point for cli main
final FileHandler fileHandler = getFileHandler();
final Executor exec = getExecutor();
- // device not connect then exit
- if ( getDevice() == null ) {
- endSDB();
- return ;
- }
-
// local widget file path control
String inputName = cmdLine.getOptionValue( OPT_WIDGETFILE );
logger.trace("input file name : {} ", inputName);
if ( StringUtil.isEmpty( inputName ) ) {
- prompter.notify( "Widget file is not selected." );
- printHelp();
- endSDB();
+ prompter.notify( FAILED_INSTALL + DESC_FAILED_CANNOT_FIND_SELECTED_WIDGET );
+ exit( 1 );
}
String widgetId = cmdLine.getOptionValue( OPT_WIDGETID );
// widget push
logger.trace( "push command");
exec.execute( push_command );
- if ( "failed".equals( push_command.getResult() ) ) {
- endSDB();
+ if ( "Failed".equals( push_command.getResult() ) ) {
+ exit ( 1 );
}
// widget mode
logger.trace( "mode command");
exec.execute( mode_command );
- if ( mode_command.getResult().contains( "failed" ) ) {
- endSDB();
+ if ( mode_command.getResult().contains( "Failed" ) ) {
+ exit ( 1 );
}
if ( !StringUtil.isEmpty( widgetId ) ) {
logger.trace( "install command");
exec.execute( install_command );
- endSDB();
+ exit( 0 );
}
/* (non-Javadoc)
return opts;
}
+
+ /* (non-Javadoc)
+ * @see org.tizen.cli.exec.WRTLauncher#getDeviceNotConnectedMessage()
+ */
+ @Override
+ protected String getDeviceNotConnectedMessage() {
+ return FAILED_INSTALL + DESC_FAILED_CANNOT_FIND_CONNECTED_DEVICE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tizen.cli.exec.WRTLauncher#getDeviceNotSelectedMessage()
+ */
+ @Override
+ protected String getDeviceNotSelectedMessage() {
+ return FAILED_INSTALL + DESC_FAILED_CANNOT_FIND_SELECTED_DEVICE;
+ }
}
import org.apache.commons.cli.CommandLine;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_CANNOT_FIND_CONNECTED_DEVICE;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_CANNOT_FIND_SELECTED_DEVICE;
+
import org.tizen.cli.exec.WRTLauncher;
import org.tizen.web.zimlaunch.cli.command.QueryCommand;
Main
extends WRTLauncher
{
+ protected String FAILED_FIND_LIST = "Failed to find list: ";
+
/**
* Entry point for cli main
*
// device not connect then exit
if ( getDevice() == null ) {
- endSDB();
- return ;
+ exit( 1 );
}
// core operation
command.setTime( getTime() );
getExecutor().execute( command );
- endSDB();
+ exit( 0 );
+ }
+
+ /* (non-Javadoc)
+ * @see org.tizen.cli.exec.WRTLauncher#getDeviceNotConnectedMessage()
+ */
+ @Override
+ protected String getDeviceNotConnectedMessage() {
+ return FAILED_FIND_LIST + DESC_FAILED_CANNOT_FIND_CONNECTED_DEVICE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tizen.cli.exec.WRTLauncher#getDeviceNotSelectedMessage()
+ */
+ @Override
+ protected String getDeviceNotSelectedMessage() {
+ return FAILED_FIND_LIST + DESC_FAILED_CANNOT_FIND_SELECTED_DEVICE;
}
}
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
-import org.tizen.cli.exec.ILaunchOptions;
+
+import static org.tizen.cli.exec.LaunchOptionConstants.OPT_WIDGETID;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_WIDGETID;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_MODE_SETTING;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_CANNOT_FIND_WIDGET_ID;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_CANNOT_FIND_CONNECTED_DEVICE;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_CANNOT_FIND_SELECTED_DEVICE;
+
import org.tizen.cli.exec.WRTLauncher;
import org.tizen.common.core.command.Executor;
import org.tizen.common.core.command.Prompter;
-import org.tizen.common.core.command.sdb.PushSdbCommand;
-import org.tizen.common.file.FileHandler;
-import org.tizen.common.file.FileHandler.Attribute;
-import org.tizen.common.util.FilenameUtil;
import org.tizen.common.util.StringUtil;
import org.tizen.web.zimlaunch.cli.command.CheckInstallCommand;
-import org.tizen.web.zimlaunch.cli.command.InstallCommand;
import org.tizen.web.zimlaunch.cli.command.KillCommand;
import org.tizen.web.zimlaunch.cli.command.ModeCommnad;
import org.tizen.web.zimlaunch.cli.command.RunCommand;
public class
Main
extends WRTLauncher
-implements ILaunchOptions
{
- /**
- * <p>
- * Description for target widget id
- *
- * This is printed out in usage
- * </p>
- *
- * @see #OPT_WIDGETID
- */
- protected static final String DESC_WIDGETID = "Command is performed of widget id uninstall in target, widget id is user written id in config.xml";
+ protected String FAILED_LAUNCH = "Failed to launch: ";
/**
* Entry point for cli main
super.execute( cmdLine );
final Prompter prompter = getPrompter();
- final FileHandler fileHandler = getFileHandler();
final Executor exec = getExecutor();
- // device not connect then exit
- if ( getDevice() == null ) {
- endSDB();
- return ;
- }
-
- // local widget file path control
- String inputName = cmdLine.getOptionValue( OPT_WIDGETFILE );
- logger.trace("input file name : {} ", inputName);
- if ( StringUtil.isEmpty( inputName ) ) {
- prompter.notify( "Widget file is not selected." );
- printHelp();
- endSDB();
- }
+ // get widget AppID
+ logger.trace( "application id value input check" );
String widgetId = cmdLine.getOptionValue( OPT_WIDGETID );
+ if ( StringUtil.isEmpty( widgetId ) ) {
+ prompter.error( FAILED_LAUNCH + DESC_FAILED_CANNOT_FIND_WIDGET_ID );
+ exit( 1 );
+ }
- String filePath = (String)fileHandler.get( inputName, Attribute.PATH );
- logger.trace( "local widget file path : {}", filePath );
-
- String fileName = FilenameUtil.getFilename( inputName );
- logger.trace( "local widget file name : {}", fileName );
-
- // core operation
- InstallCommand install_command = new InstallCommand();
- install_command.setWidget( fileName );
- install_command.setDevice( getDevice() );
- install_command.setTime( getTime() );
- install_command.setPrintOption( false );
- String remotePath = install_command.getRemotePath() + fileName;
- logger.trace( "remote widget file path : {}", remotePath );
-
- PushSdbCommand push_command = new PushSdbCommand( filePath, remotePath );
- push_command.setDevice( getDevice() );
-
+ // mode command
ModeCommnad mode_command = new ModeCommnad();
mode_command.setDevice( getDevice() );
mode_command.setTime( getTime() );
-
- // widget push
- logger.trace( "push command");
- exec.execute( push_command );
- if ( "failed".equals( push_command.getResult() ) ) {
- endSDB();
- }
+ mode_command.setPrintOption( false );
// widget mode
logger.trace( "mode command");
exec.execute( mode_command );
if ( mode_command.getResult().contains( "failed" ) ) {
- endSDB();
+ prompter.error( FAILED_LAUNCH + DESC_FAILED_MODE_SETTING );
+ exit( 1 );
}
+ // already run check and kill
if ( !StringUtil.isEmpty( widgetId ) ) {
logger.trace( "same widget's pre-install check and kill process" );
CheckInstallCommand check_install_cmd = new CheckInstallCommand( widgetId );
}
}
- // widget install
- logger.trace( "install command");
- exec.execute( install_command );
-
// widget run
RunCommand run_command = new RunCommand( widgetId );
run_command.setDevice( getDevice() );
run_command.setTime( getTime() );
+ run_command.setPrintOption( false );
exec.execute( run_command );
- endSDB();
+ prompter.notify( run_command.getResult() );
+ if ( run_command.getResult().contains( "failed" ) ) {
+ exit( 1 );
+ } else {
+ exit( 0 );
+ }
}
/* (non-Javadoc)
getOptions()
{
final Options opts = super.getOptions();
- opts.addOption( OptionBuilder.hasArg().isRequired().withLongOpt( OPT_WIDGETFILE ).withDescription( DESC_WIDGETFILE ).create( OPT_WIDGETFILE.substring( 0, 1 ) ) );
opts.addOption( OptionBuilder.hasArg().isRequired().withLongOpt( OPT_WIDGETID ).withDescription( DESC_WIDGETID ).create( OPT_WIDGETID.substring( 0, 1 ) ) );
return opts;
}
+
+ /* (non-Javadoc)
+ * @see org.tizen.cli.exec.WRTLauncher#getDeviceNotConnectedMessage()
+ */
+ @Override
+ protected String getDeviceNotConnectedMessage() {
+ return FAILED_LAUNCH + DESC_FAILED_CANNOT_FIND_CONNECTED_DEVICE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tizen.cli.exec.WRTLauncher#getDeviceNotSelectedMessage()
+ */
+ @Override
+ protected String getDeviceNotSelectedMessage() {
+ return FAILED_LAUNCH + DESC_FAILED_CANNOT_FIND_SELECTED_DEVICE;
+ }
}
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
+
+import static org.tizen.cli.exec.LaunchOptionConstants.OPT_NOCHECK;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_NOCHECK;
+import static org.tizen.cli.exec.LaunchOptionConstants.OPT_INCLUDE;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_INCLUDE;
+import static org.tizen.cli.exec.LaunchOptionConstants.OPT_EXCLUDE;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_EXCLUDE;
+
import org.tizen.cli.exec.AbstractLauncher;
-import org.tizen.cli.exec.ILaunchOptions;
import org.tizen.common.core.command.Prompter;
import org.tizen.common.core.command.prompter.ChoiceOption;
import org.tizen.common.core.command.prompter.Option;
public class
Main
extends AbstractLauncher
-implements ILaunchOptions
{
/**
import org.tizen.cli.command.PluginConstants;
import org.tizen.cli.command.SearchTemplate;
import org.tizen.cli.exec.AbstractLauncher;
-import org.tizen.cli.exec.ILaunchOptions;
import org.tizen.cli.util.TemplateModelProvider;
import org.tizen.common.config.Preference;
import org.tizen.common.verrari.Realm;
public class
ClientMain
extends AbstractLauncher
-implements ILaunchOptions
{
protected static final String OPT_REALM = "realm";
import java.text.MessageFormat;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_CANNOT_FIND_CONNECTED_DEVICE;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_FAILED_CANNOT_FIND_SELECTED_DEVICE;
+import static org.tizen.cli.exec.LaunchOptionConstants.OPT_WIDGETID;
+
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
-import org.tizen.cli.exec.ILaunchOptions;
import org.tizen.cli.exec.WRTLauncher;
import org.tizen.common.core.command.Executor;
import org.tizen.common.core.command.Prompter;
public class
Main
extends WRTLauncher
-implements ILaunchOptions
{
+ protected String FAILED_UNINSTALL = "Failed to uninstall: ";
+
/**
* <p>
* Description for target widget id
final Prompter prompter = getPrompter();
final Executor exec = getExecutor();
- // device not connect then exit
- if ( getDevice() == null ) {
- endSDB();
- return ;
- }
-
// core operation
String widgetID = cmdLine.getOptionValue( OPT_WIDGETID );
prompter.notify(
MessageFormat.format( "Uninstall failed, ''{0}'' widget is not installed.", widgetID )
);
- endSDB();
- return ;
+ exit( 1 );
}
// kill
uninstall_command.setTime( getTime() );
exec.execute( uninstall_command );
- endSDB();
+ exit( 0 );
}
/* (non-Javadoc)
return opts;
}
+
+ /* (non-Javadoc)
+ * @see org.tizen.cli.exec.WRTLauncher#getDeviceNotConnectedMessage()
+ */
+ @Override
+ protected String getDeviceNotConnectedMessage() {
+ return FAILED_UNINSTALL+ DESC_FAILED_CANNOT_FIND_CONNECTED_DEVICE;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tizen.cli.exec.WRTLauncher#getDeviceNotSelectedMessage()
+ */
+ @Override
+ protected String getDeviceNotSelectedMessage() {
+ return FAILED_UNINSTALL+ DESC_FAILED_CANNOT_FIND_SELECTED_DEVICE;
+ }
}
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
+
+import static org.tizen.cli.exec.LaunchOptionConstants.OPT_NOCHECK;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_NOCHECK;
+import static org.tizen.cli.exec.LaunchOptionConstants.OPT_INCLUDE;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_INCLUDE;
+import static org.tizen.cli.exec.LaunchOptionConstants.OPT_EXCLUDE;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_EXCLUDE;
+import static org.tizen.cli.exec.LaunchOptionConstants.OPT_OVERWRITE;
+import static org.tizen.cli.exec.LaunchOptionConstants.DESC_OVERWRITE;
+
import org.tizen.cli.exec.AbstractLauncher;
-import org.tizen.cli.exec.ILaunchOptions;
+import org.tizen.cli.exec.LaunchOptionConstants;
import org.tizen.common.core.command.Executor;
import org.tizen.common.core.command.Prompter;
import org.tizen.common.core.command.prompter.ChoiceOption;
public class
Main
extends AbstractLauncher
-implements ILaunchOptions
{
import java.util.concurrent.atomic.AtomicBoolean;
+import static org.tizen.cli.exec.LaunchOptionConstants.*;
+
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.PosixParser;
final PosixParser parser = new PosixParser();
parser.parse( opts, new String[] {
- "-help", "-quiet", "-device", "deviceName", "-widget", "test.wgt", "-id", "http://test.com"
+ "-help", "-quiet", "-device", "deviceName", "-id", "http://test.com"
} );
parser.parse( opts, new String[] {
- "--help", "--quiet", "--device", "deviceName", "--widget", "test.wgt", "--id", "http://test.com"
+ "--help", "--quiet", "--device", "deviceName", "--id", "http://test.com"
} );
parser.parse( opts, new String[] {
- "-h", "-q", "-d", "deviceName", "-w", "test.wgt", "-i", "http://test.com"
+ "-h", "-q", "-d", "deviceName", "-i", "http://test.com"
} );
try {
{
final CommandLine cmd = parser.parse( opts, new String[] {
- "--log=trace", "--device", "TestDevice", "--id", "http://test.com", "--widget", "test.wgt"
+ "--log=trace", "--device", "TestDevice", "--id", "http://test.com"
} );
- final String[] args1 = cmd.getOptionValues( Main.OPT_WIDGETID );
+ final String[] args1 = cmd.getOptionValues( OPT_WIDGETID );
assertEquals( 1, args1.length );
assertEquals( "http://test.com", args1[0] );
final String[] shortArgs1 = cmd.getOptionValues( "i" );
assertEquals( 1, shortArgs1.length );
assertEquals( "http://test.com", shortArgs1[0] );
-
- final String[] args2 = cmd.getOptionValues( Main.OPT_WIDGETFILE );
- assertEquals( 1, args2.length );
- assertEquals( "test.wgt", args2[0] );
- final String[] shortArgs2 = cmd.getOptionValues( "w" );
- assertEquals( 1, shortArgs2.length );
- assertEquals( "test.wgt", shortArgs2[0] );
}
{
final CommandLine cmd = parser.parse( opts, new String[] {
- "--log=debug", "-i", "http://test.com", "-w", "test.wgt"
+ "--log=debug", "-i", "http://test.com"
} );
- final String[] args1 = cmd.getOptionValues( Main.OPT_WIDGETID );
+ final String[] args1 = cmd.getOptionValues( OPT_WIDGETID );
assertNotNull( args1 );
- final String[] args2 = cmd.getOptionValues( Main.OPT_WIDGETFILE );
- assertNotNull( args2 );
}
}
}
};
- testClass.run( "-d", "TestDevice", "-i", "http://test.com", "-w", "test.wgt" );
+ testClass.run( "-d", "TestDevice", "-i", "http://test.com" );
assertTrue( result.get() );
}
}
import java.util.concurrent.atomic.AtomicBoolean;
+import static org.tizen.cli.exec.LaunchOptionConstants.*;
+
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.PosixParser;
final CommandLine cmd = parser.parse( opts, new String[] {
"--log=trace", "--name", "myproject", "--path", "/home/myproject"
} );
- final String[] args1 = cmd.getOptionValues( Main.OPT_NAME );
+ final String[] args1 = cmd.getOptionValues( 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 );
+ final String[] args2 = cmd.getOptionValues( OPT_PATH );
assertEquals( 1, args2.length );
assertEquals( "/home/myproject", args2[0] );
final String[] shortArgs2 = cmd.getOptionValues( "p" );
final CommandLine cmd = parser.parse( opts, new String[] {
"--log=debug", "-n", "myproject", "-p", "/home/myproject"
} );
- final String[] args1 = cmd.getOptionValues( Main.OPT_NAME );
+ final String[] args1 = cmd.getOptionValues( OPT_NAME );
assertNotNull( args1 );
- final String[] args2 = cmd.getOptionValues( Main.OPT_PATH );
+ final String[] args2 = cmd.getOptionValues( OPT_PATH );
assertNotNull( args2 );
}
}
import java.util.concurrent.atomic.AtomicBoolean;
+import static org.tizen.cli.exec.LaunchOptionConstants.*;
+
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.PosixParser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tizen.cli.exec.AbstractMainTest;
+import org.tizen.cli.exec.install.Main;
import org.tizen.common.core.command.Executor;
/**
{
final CommandLine cmd = parser.parse( opts, new String[] { "--log=trace", "--device", "TestDevice", "--widget", "test.wgt" } );
- final String[] args = cmd.getOptionValues( Main.OPT_WIDGETFILE );
+ final String[] args = cmd.getOptionValues( OPT_WIDGETFILE );
assertEquals( 1, args.length );
assertEquals( "test.wgt", args[0] );
final String[] shortArgs = cmd.getOptionValues( "w" );
{
final CommandLine cmd = parser.parse( opts, new String[] { "--log=debug", "-w", "test.wgt" } );
- final String[] args = cmd.getOptionValues( Main.OPT_WIDGETFILE );
+ final String[] args = cmd.getOptionValues( OPT_WIDGETFILE );
assertNotNull( args );
}
}
import java.util.concurrent.atomic.AtomicBoolean;
+import static org.tizen.cli.exec.LaunchOptionConstants.*;
+
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.PosixParser;
final PosixParser parser = new PosixParser();
parser.parse( opts, new String[] {
- "-help", "-quiet", "-device", "deviceName", "-widget", "test.wgt", "-id", "http://test.com"
+ "-help", "-quiet", "-device", "deviceName", "-id", "http://test.com"
} );
parser.parse( opts, new String[] {
- "--help", "--quiet", "--device", "deviceName", "--widget", "test.wgt", "--id", "http://test.com"
+ "--help", "--quiet", "--device", "deviceName", "--id", "http://test.com"
} );
parser.parse( opts, new String[] {
- "-h", "-q", "-d", "deviceName", "-w", "test.wgt", "-i", "http://test.com"
+ "-h", "-q", "-d", "deviceName", "-i", "http://test.com"
} );
try {
{
final CommandLine cmd = parser.parse( opts, new String[] {
- "--log=trace", "--device", "TestDevice", "--id", "http://test.com", "--widget", "test.wgt"
+ "--log=trace", "--device", "TestDevice", "--id", "http://test.com"
} );
- final String[] args1 = cmd.getOptionValues( Main.OPT_WIDGETID );
+ final String[] args1 = cmd.getOptionValues( OPT_WIDGETID );
assertEquals( 1, args1.length );
assertEquals( "http://test.com", args1[0] );
final String[] shortArgs1 = cmd.getOptionValues( "i" );
assertEquals( 1, shortArgs1.length );
assertEquals( "http://test.com", shortArgs1[0] );
-
- final String[] args2 = cmd.getOptionValues( Main.OPT_WIDGETFILE );
- assertEquals( 1, args2.length );
- assertEquals( "test.wgt", args2[0] );
- final String[] shortArgs2 = cmd.getOptionValues( "w" );
- assertEquals( 1, shortArgs2.length );
- assertEquals( "test.wgt", shortArgs2[0] );
}
{
final CommandLine cmd = parser.parse( opts, new String[] {
- "--log=debug", "-i", "http://test.com", "-w", "test.wgt"
+ "--log=debug", "-i", "http://test.com"
} );
- final String[] args1 = cmd.getOptionValues( Main.OPT_WIDGETID );
+ final String[] args1 = cmd.getOptionValues( OPT_WIDGETID );
assertNotNull( args1 );
- final String[] args2 = cmd.getOptionValues( Main.OPT_WIDGETFILE );
- assertNotNull( args2 );
}
}
}
};
- testClass.run( "-d", "TestDevice", "-i", "http://test.com", "-w", "test.wgt" );
+ testClass.run( "-d", "TestDevice", "-i", "http://test.com" );
assertTrue( result.get() );
}
}
import java.util.concurrent.atomic.AtomicBoolean;
+import static org.tizen.cli.exec.LaunchOptionConstants.*;
+
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.PosixParser;
{
final CommandLine cmd = parser.parse( opts, new String[] { "--exclude", "hello", "--log=trace", "--exclude", "message2", "--profile", "test:/test/prfiles.xml" } );
- final String[] args = cmd.getOptionValues( Main.OPT_EXCLUDE );
+ final String[] args = cmd.getOptionValues( OPT_EXCLUDE );
assertEquals( 2, args.length );
assertEquals( "hello", args[0] );
assertEquals( "message2", args[1] );
{
final CommandLine cmd = parser.parse( opts, new String[] { "--log=debug", "-p", "test:/test/prfiles.xml" } );
- final String[] args = cmd.getOptionValues( Main.OPT_EXCLUDE );
+ final String[] args = cmd.getOptionValues( OPT_EXCLUDE );
assertNull( args );
}
}
import java.util.concurrent.atomic.AtomicBoolean;
+import static org.tizen.cli.exec.LaunchOptionConstants.*;
+
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.PosixParser;
{
final CommandLine cmd = parser.parse( opts, new String[] { "--log=trace", "--device", "TestDevice", "--id", "http://test.com" } );
- final String[] args = cmd.getOptionValues( Main.OPT_WIDGETID );
+ final String[] args = cmd.getOptionValues( OPT_WIDGETID );
assertEquals( 1, args.length );
assertEquals( "http://test.com", args[0] );
final String[] shortArgs = cmd.getOptionValues( "i" );
{
final CommandLine cmd = parser.parse( opts, new String[] { "--log=debug", "-i", "http://test.com" } );
- final String[] args = cmd.getOptionValues( Main.OPT_WIDGETID );
+ final String[] args = cmd.getOptionValues( OPT_WIDGETID );
assertNotNull( args );
}
}
import static org.tizen.common.util.IOUtil.getBytes;
import static org.tizen.common.util.IOUtil.tryClose;
+import static org.tizen.cli.exec.LaunchOptionConstants.*;
+
import java.io.InputStream;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.zip.ZipEntry;
{
final CommandLine cmd = parser.parse( opts, new String[] { "--exclude", "hello", "--log=trace", "--exclude", "message2" } );
- final String[] args = cmd.getOptionValues( Main.OPT_EXCLUDE );
+ final String[] args = cmd.getOptionValues( OPT_EXCLUDE );
assertArrayEquals( new String[] { "hello", "message2" }, args );
final String[] shortArgs = cmd.getOptionValues( "e" );
assertArrayEquals( new String[] { "hello", "message2" }, shortArgs );
{
final CommandLine cmd = parser.parse( opts, new String[] { "--log=debug" } );
- final String[] args = cmd.getOptionValues( Main.OPT_EXCLUDE );
+ final String[] args = cmd.getOptionValues( OPT_EXCLUDE );
assertNull( args );
}
final CommandLine cmd = parser.parse( opts, new String[] { "--include", "*.html" } );
final String[] args = cmd.getArgs();
assertTrue( isEmpty( args ) );
- assertArrayEquals( new String[] { "*.html" }, cmd.getOptionValues( Main.OPT_INCLUDE ) );
+ assertArrayEquals( new String[] { "*.html" }, cmd.getOptionValues( OPT_INCLUDE ) );
}
}