From: Bonyong.lee Date: Tue, 3 Jul 2012 04:39:57 +0000 (+0100) Subject: [Title] Merge cli branch X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=55cd833d33cf8d61702291b6e7c8ea25a96add79;p=sdk%2Ftools%2Fcli.git [Title] Merge cli branch [Type] Enhancement [Module] Sub [Priority] Minor [CQ#] [Redmine#] [Problem] [Cause] [Solution] [TestCase] --- diff --git a/.gitignore b/.gitignore index e69de29..fd9ed35 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,11 @@ +#binary files +build_result +bin +*.class +common-eplugin_*.tar.gz +common-eplugin_*_*.zip +common-eplugin.package.linux +common-eplugin.package.windows +#log files +.log + diff --git a/org.tizen.cli/.classpath b/org.tizen.cli/.classpath new file mode 100644 index 0000000..c879acc --- /dev/null +++ b/org.tizen.cli/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/org.tizen.cli/.project b/org.tizen.cli/.project new file mode 100644 index 0000000..16a12da --- /dev/null +++ b/org.tizen.cli/.project @@ -0,0 +1,28 @@ + + + org.tizen.cli + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/org.tizen.cli/.settings/org.eclipse.jdt.core.prefs b/org.tizen.cli/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..c328be6 --- /dev/null +++ b/org.tizen.cli/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Thu Jun 07 10:18:19 KST 2012 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/org.tizen.cli/.settings/org.eclipse.pde.core.prefs b/org.tizen.cli/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 0000000..d778992 --- /dev/null +++ b/org.tizen.cli/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,4 @@ +#Thu Jun 07 10:18:19 KST 2012 +eclipse.preferences.version=1 +pluginProject.extensions=false +resolve.requirebundle=false diff --git a/org.tizen.cli/META-INF/MANIFEST.MF b/org.tizen.cli/META-INF/MANIFEST.MF new file mode 100644 index 0000000..985a308 --- /dev/null +++ b/org.tizen.cli/META-INF/MANIFEST.MF @@ -0,0 +1,13 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Command Line Interface +Bundle-SymbolicName: org.tizen.cli;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: Samsung +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Require-Bundle: org.tizen.common, + org.tizen.web.common, + org.tizen.web.sign +Bundle-ClassPath: ., + lib/ant.jar, + lib/commons-cli-1.2.jar diff --git a/org.tizen.cli/build.properties b/org.tizen.cli/build.properties new file mode 100644 index 0000000..45e04ba --- /dev/null +++ b/org.tizen.cli/build.properties @@ -0,0 +1,11 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + lib/ant.jar,\ + lib/commons-cli-1.2.jar +source.lib/commons-cli-1.2.jar = +jars.compile.order = .,\ + lib/commons-cli-1.2.jar,\ + lib/ant.jar +source.lib/ant.jar = diff --git a/org.tizen.cli/doc/shell/sign b/org.tizen.cli/doc/shell/sign new file mode 100644 index 0000000..0563925 --- /dev/null +++ b/org.tizen.cli/doc/shell/sign @@ -0,0 +1,65 @@ +#!/bin/sh + +MAIN=org.tizen.cli.exec.sign.Main + +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 + +DIR_BIN=`dirname $SCRIPT` +DIR_HOME=$DIR_BIN/.. +DIR_LIB=$DIR_HOME/lib +DIR_CONFIG=$DIR_HOME/conf + +JARS=`find $DIR_LIB -name "*.jar"` + +JAR="" +for JAR_FILE in $JARS; do + JAR=$JAR:$JAR_FILE +done + +CLASSPATH=$DIR_CONFIG:$JAR + +OPT_LOGGING="-Dlog4j.configuration=log4j.xml" +OPT_PRG_NAME="-Dcli.name=$SCRIPT" + +READ_ARG="n" + +OPT_TRACE= + +for WORD in $@; do + if [ "y" = "$READ_ARG" ] + then + OPT_LOGGING="-Dlog4j.configuration=log4j-${WORD}.xml" + if [ "$WORD" = "trace" ] + then + OPT_TRACE="-Dlog4j.debug=true" + fi + READ_ARG="n" + fi + case $WORD in + "--log" | "-l" ) + READ_ARG="y" + ;; + esac +done + +OPT="$OPT_TRACE $OPT_LOGGING $OPT_PRG_NAME" + +EXEC="java -cp $CLASSPATH $OPT $MAIN $@" + +if [ -n "$OPT_TRACE" ] +then + echo "Command :$EXEC" +fi + +$EXEC diff --git a/org.tizen.cli/doc/shell/wgt b/org.tizen.cli/doc/shell/wgt new file mode 100644 index 0000000..93b141f --- /dev/null +++ b/org.tizen.cli/doc/shell/wgt @@ -0,0 +1,65 @@ +#!/bin/sh + +MAIN=org.tizen.cli.exec.wgt.Main + +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 + +DIR_BIN=`dirname $SCRIPT` +DIR_HOME=$DIR_BIN/.. +DIR_LIB=$DIR_HOME/lib +DIR_CONFIG=$DIR_HOME/conf + +JARS=`find $DIR_LIB -name "*.jar"` + +JAR="" +for JAR_FILE in $JARS; do + JAR=$JAR:$JAR_FILE +done + +CLASSPATH=$DIR_CONFIG:$JAR + +OPT_LOGGING="-Dlog4j.configuration=log4j.xml" +OPT_PRG_NAME="-Dcli.name=$SCRIPT" + +READ_ARG="n" + +OPT_TRACE= + +for WORD in $@; do + if [ "y" = "$READ_ARG" ] + then + OPT_LOGGING="-Dlog4j.configuration=log4j-${WORD}.xml" + if [ "$WORD" = "trace" ] + then + OPT_TRACE="-Dlog4j.debug=true" + fi + READ_ARG="n" + fi + case $WORD in + "--log" | "-l" ) + READ_ARG="y" + ;; + esac +done + +OPT="$OPT_TRACE $OPT_LOGGING $OPT_PRG_NAME" +ARGS=`echo "$@"` +EXEC="java -cp $CLASSPATH $OPT $MAIN $ARGS" + +if [ -n "$OPT_TRACE" ] +then + echo "Command :$EXEC" +fi + +$EXEC diff --git a/org.tizen.cli/lib/ant.jar b/org.tizen.cli/lib/ant.jar new file mode 100644 index 0000000..b3a94df Binary files /dev/null and b/org.tizen.cli/lib/ant.jar differ diff --git a/org.tizen.cli/lib/commons-cli-1.2.jar b/org.tizen.cli/lib/commons-cli-1.2.jar new file mode 100644 index 0000000..ce4b9ff Binary files /dev/null and b/org.tizen.cli/lib/commons-cli-1.2.jar differ diff --git a/org.tizen.cli/src/org/tizen/cli/exec/AbstractLauncher.java b/org.tizen.cli/src/org/tizen/cli/exec/AbstractLauncher.java new file mode 100644 index 0000000..9096f5a --- /dev/null +++ b/org.tizen.cli/src/org/tizen/cli/exec/AbstractLauncher.java @@ -0,0 +1,522 @@ +/* + * Web IDE - Command Line Interface + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * BonYong Lee + * + * 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; + +import static org.tizen.common.util.StringUtil.nvl; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.io.StringWriter; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.CommandLineParser; +import org.apache.commons.cli.GnuParser; +import org.apache.commons.cli.HelpFormatter; +import org.apache.commons.cli.OptionBuilder; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.ParseException; +import org.apache.commons.cli.PosixParser; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.tizen.common.core.command.ExecutionContext; +import org.tizen.common.core.command.Executor; +import org.tizen.common.core.command.Prompter; +import org.tizen.common.core.command.policy.PolicyRegistry; +import org.tizen.common.file.FileHandler; +import org.tizen.common.file.FileHandler.Attribute; +import org.tizen.common.file.StandardFileHandler; +import org.tizen.common.util.MapUtil; + +/** + *

+ * AbstractLauncher. + * + * abstract class for simple command. + * + * provide {@link ExecutionContext} for command line + *

+ * + * @author BonYong Lee{@literal } (S-Core) + */ +abstract public class +AbstractLauncher +{ + /** + * Program name property key + */ + protected static final String PROP_PRG = "cli.name"; + + /** + *

+ * Option for help text + *

+ */ + protected static final String OPT_HELP = "help"; + + /** + *

+ * Description for help option + * + * This is printed out in usage + *

+ * + * @see #OPT_HELP + */ + protected static final String DESC_HELP = "print out this page"; + + /** + *

+ * Option for log level + * + * This option is shared in shell + *

+ */ + protected static final String OPT_LOG = "log"; + + /** + *

+ * Description for log level option + * + * This is printed out in usage + *

+ * + * @see #OPT_LOG + */ + protected static final String DESC_LOG = "specify log level( ex - error, warn, info, debug, trace, none )"; + + /** + *

+ * Option for no output + *

+ */ + protected static final String OPT_QUIET = "quiet"; + + /** + *

+ * Description for no output option + * + * This is printed out in usage + *

+ * + * @see #OPT_QUIET + */ + protected static final String DESC_QUIET = "execute silently"; + + /** + *

+ * Property key for command line parameter parser + *

+ */ + protected static final String PROP_PARSER = "tizen.cli.parser"; + + /** + *

+ * logger for this object + *

+ */ + protected final Logger logger = LoggerFactory.getLogger( getClass() ); + + /** + *

+ * optional flag to be specified by user + * + * flag is formatted in POSIX style in default + *

+ */ + protected CommandLine cmd; + + /** + * {@link Executor} for Command Line Interface + */ + protected Executor executor; + + /** + * Convert path to canonical path + * + * @param path relative or abstract path + * + * @return canonical path + * + * @throws IOException If file system deny request + */ + protected + String + convertPath( + final String path + ) + throws IOException + { + final FileHandler fileHandler = getFileHandler(); + return (String) fileHandler.get( path, Attribute.PATH ); + } + + /** + * return execution command for usage + * + * @return execution command + */ + protected String getSyntax() + { + return nvl( System.getProperty( PROP_PRG ), "java " + getClass().getName() ); + } + + /** + * {@link Options} for usage + * + * @return defined {@link Options} + */ + @SuppressWarnings("static-access") + protected + Options + getOptions() + { + final Options options = new Options(); + + options.addOption( OptionBuilder.withLongOpt( OPT_HELP ).withDescription( DESC_HELP ).create( OPT_HELP.substring( 0, 1 ) ) ); + options.addOption( OptionBuilder.hasArg().withLongOpt( OPT_LOG ).withDescription( DESC_LOG ).create( OPT_LOG.substring( 0, 1 ) ) ); + options.addOption( OptionBuilder.withLongOpt( OPT_QUIET ).withDescription( DESC_QUIET ).create( OPT_QUIET.substring( 0, 1 ) ) ); + + return options; + } + + /** + * Print out usage + * + * @return usage string + */ + protected + String + printHelp() + { + final HelpFormatter formatter = new HelpFormatter(); + + final StringWriter writer = new StringWriter(); + + final PrintWriter stream = new PrintWriter( writer ); + + formatter.printHelp( + stream, + formatter.getWidth(), + getSyntax(), + null, + getOptions(), + formatter.getLeftPadding(), + formatter.getDescPadding(), + null, + false + ); + + final String help = writer.toString(); + + getPrompter().error( help ); + + return help; + } + + + /** + * Entry method for execution + * + * @param args command line argument + * + * @throws Exception If unhandled exception occured + */ + public void + run( + final String... args + ) + throws Exception + { + executor = new CommandLineExecutor( + new ConsolePrompter( System.out, new InputStreamReader( System.in ) ) + ); + if ( logger.isTraceEnabled() ) + { + logger.trace( "System properties :\n{}", MapUtil.toString( System.getProperties() ) ); + } + + + try + { + this.cmd = parse( args ); + + if ( cmd.hasOption( OPT_QUIET ) ) + { + executor = new CommandLineExecutor( + new ConsolePrompter( new PrintStream( new OutputStream() { + public void write(int b) throws IOException { + } + } ), new InputStreamReader( System.in ) ) + ); + + } + + if ( cmd.hasOption( OPT_HELP ) ) + { + printHelp(); + return ; + } + + execute( cmd ); + } + catch ( final ParseException e ) + { + printHelp(); + } + catch ( final Exception e ) + { + handleException( e ); + } + } + + /** + * Handle uncaught exception + * + * @param e uncaught exception + */ + protected + void + handleException( + final Exception e + ) + { + logger.error( "Command stop because of exception", e ); + + Throwable iter = e; + while ( null != iter ) + { + final String localMessage = iter.getLocalizedMessage(); + if ( null != localMessage ) + { + logger.error( localMessage ); + return ; + } + + final String message = iter.getMessage(); + if ( null != message ) + { + logger.error( message ); + return ; + } + iter = iter.getCause(); + } + + } + + /** + * Parse arguments args with {@link CommandLineParser} + * + * @param args arguments to parse + * + * @return {@link CommandLine} to be parsed + * + * @throws InstantiationException If custom parser is invalid + * @throws IllegalAccessException If custom parser is invalid + * @throws ParseException If arguements is invalid + */ + protected + CommandLine + parse( + final String... args + ) + throws InstantiationException, IllegalAccessException, ParseException + { + final CommandLineParser parser = getParser(); + + final Options options = getOptions(); + + final CommandLine cmdLine = parser.parse( options, args ); + + return cmdLine; + } + + /** + * Return default parser {@link Class} + * + * @return {@link Class} for default parser + */ + protected + static + Class + getDefaultParserClass() + { + return PosixParser.class; + } + + /** + * Return parser along user selection. + * + * The selection is specified JVM system properties + * + * Support two built-in parser + *
    + *
  • POSIX style - tar -zxvf foo.tar.gz
  • + *
  • GNU style - du --human-readable --max-depth=1
  • + *
+ * + * if you want use custom parser, specify class name + * + * @return {@link CommandLineParser} to parse + * + * @throws InstantiationException If custom parser can't be instantiated + * @throws IllegalAccessException If custom parser's constructor is NOT accessible + * + * @see #PROP_PARSER + * @see CommandLineParser + */ + protected + CommandLineParser + getParser() + throws InstantiationException, IllegalAccessException { + final String parserName = System.getProperty( PROP_PARSER ); + logger.trace( "Parser name :{}", parserName ); + Class parserClazz = getDefaultParserClass(); + try { + if ( null != parserName ) + { + parserClazz = Class.forName( parserName ); + } + } + catch ( final ClassNotFoundException e ) + { + if ( "posix".equalsIgnoreCase( parserName ) ) + { // tar -zxvf foo.tar.gz + parserClazz = PosixParser.class; + } + else if ( "gnu".equalsIgnoreCase( parserName ) ) + { + parserClazz = GnuParser.class; + } + else + { + logger.warn( "Invalid argument parser :" + parserName ); + } + } + + logger.trace( "Parser class :{}", parserClazz ); + + return (CommandLineParser) parserClazz.newInstance(); + } + + /** + * Return managed command line arguments + * + * @return managed arguments + * + * @see CommandLine + */ + protected + CommandLine + getCommandLine() + { + return this.cmd; + } + + /** + * Return defined executor for command + * + * @return {@link ExecutionContext} to use + */ + protected + Executor + getExecutor() + { + if ( null == executor ) + { + this.executor = new Executor(); + } + + return executor; + } + + /** + * Return {@link ExecutionContext} in cli + * + * @return {@link ExecutionContext} + */ + protected + ExecutionContext + getExecutionContext() + { + return getExecutor().getContext(); + } + + /** + * Return {@link PolicyRegistry} in cli + * + * @return {@link PolicyRegistry} + */ + protected + PolicyRegistry + getPolicy() + { + return getExecutionContext().getPolicyRegistry(); + } + + /** + * Return {@link FileHandler} in cli + * + * @return {@link FileHandler} + * + * @see #getExecutionContext() + * @see StandardFileHandler + */ + protected + FileHandler + getFileHandler() + { + return getExecutionContext().getFileHandler(); + } + + /** + * Return {@link Prompter} in cli + * + * @return {@link Prompter} + * + * @see #getExecutionContext() + */ + protected + Prompter + getPrompter() + { + return getExecutionContext().getPrompter(); + } + + /** + * Execute command + * + * Implement execution of command + * + * @param cmdLine arguments + * + * @throws Exception If Unhandled exception occured + */ + abstract protected void execute( CommandLine cmdLine ) throws Exception; + + +} diff --git a/org.tizen.cli/src/org/tizen/cli/exec/CommandLineExecutor.java b/org.tizen.cli/src/org/tizen/cli/exec/CommandLineExecutor.java new file mode 100644 index 0000000..d839bb0 --- /dev/null +++ b/org.tizen.cli/src/org/tizen/cli/exec/CommandLineExecutor.java @@ -0,0 +1,130 @@ +/* + * Web IDE - Command Line Interface + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * BonYong Lee + * + * 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; + +import java.text.MessageFormat; + +import org.tizen.common.Factory; +import org.tizen.common.core.command.ExecutionContext; +import org.tizen.common.core.command.Executor; +import org.tizen.common.core.command.Prompter; +import org.tizen.common.core.command.policy.PolicyRegistry; +import org.tizen.common.file.FileHandler; +import org.tizen.common.file.StandardFileHandler; + +/** + *

+ * CommandLineExecutor. + * + * {@link Executor} for commaand line interface + *

+ * + * @author BonYong Lee{@literal } (S-Core) + */ +public class +CommandLineExecutor +extends Executor +{ + + /** + * Contructor with prompter + * + * @param prompter {@link Prompter} + */ + public + CommandLineExecutor( + final Prompter prompter + ) + { + super( + new Factory() { + + /** + * {@link FileHandler} for Command Line Interface + */ + protected FileHandler fileHandler = new StandardFileHandler(); + + + /** + *

+ * {@link PolicyRegistry} for Command Line Interface + *

+ */ + protected Factory factory = new PolicyRegistryFactory(); + + /** + * Create and return {@link PolicyRegistry} + * + * @return {@link PolicyRegistry} to be created + */ + protected + PolicyRegistry + getRegistry() + { + return factory.create(); + } + + /** + * {@link ExecutionContext} for Command Line Interface + */ + protected + final + ExecutionContext context = new ExecutionContext( + getRegistry(), + prompter, + fileHandler + ); + + /* (non-Javadoc) + * @see org.tizen.common.core.command.ExecutionContextFactory#create() + */ + @Override + public + ExecutionContext + create() + { + return context; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public + String + toString() + { + return MessageFormat.format( + "Policy :{0}, Prompter :{1}, File Handler :{2}", + context.getPolicyRegistry(), + context.getPrompter(), + context.getFileHandler() + ); + }; + } + ); + } + +} diff --git a/org.tizen.cli/src/org/tizen/cli/exec/ConsolePrompter.java b/org.tizen.cli/src/org/tizen/cli/exec/ConsolePrompter.java new file mode 100644 index 0000000..7be1719 --- /dev/null +++ b/org.tizen.cli/src/org/tizen/cli/exec/ConsolePrompter.java @@ -0,0 +1,227 @@ +/* + * Web IDE - Command Line Interface + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * BonYong Lee + * + * 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; + +import static org.tizen.common.util.StringUtil.isEmpty; +import static org.tizen.common.util.StringUtil.trim; + +import java.io.BufferedReader; +import java.io.Console; +import java.io.IOException; +import java.io.PrintStream; +import java.io.Reader; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.LinkedHashSet; + +import org.tizen.common.core.command.Prompter; +import org.tizen.common.core.command.prompter.AbstractPrompter; +import org.tizen.common.core.command.prompter.Option; +import org.tizen.common.util.ArrayUtil; +import org.tizen.common.util.Assert; +import org.tizen.common.util.CollectionUtil; + +/** + *

+ * ConsolePrompter. + * + * {@link Prompter} for command line interface + * + * Print out using {@link PrintStream} and Read input from console( including standard input ) + *

+ * + * @author BonYong Lee{@literal } (S-Core) + */ +public class +ConsolePrompter +extends AbstractPrompter +implements Prompter +{ + /** + * {@link PrintStream} for output + */ + protected final PrintStream out; + + /** + * {@link BufferedReader} for input + */ + protected final BufferedReader reader; + + /** + * Flag about cancellation + */ + protected boolean bCancel = false; + + /** + * Constructor with {@link PrintStream} and {@link Reader} + * + * @param out {@link PrintStream} for output + * @param reader {@link Reader} for input + */ + public + ConsolePrompter( + final PrintStream out, + final Reader reader + ) + { + Assert.notNull( out ); + this.out = out; + this.reader = new BufferedReader( reader ); + } + + /* (non-Javadoc) + * @see org.tizen.common.core.command.Prompter#interact(java.lang.String, int, org.tizen.common.core.command.prompter.Option[]) + */ + @Override + public + Option + interact( + final String question, + final Option... options + ) + { + final HashSet