askConfirmation() 공개 메소드

The question will be asked until the user answer by nothing, yes, or no.
public askConfirmation ( Symfony\Component\Console\Output\OutputInterface $output, string | array $question, boolean $default = true ) : boolean
$output Symfony\Component\Console\Output\OutputInterface
$question string | array The question to ask
$default boolean The default answer if the user enters nothing
리턴 boolean true if the user has confirmed, false otherwise
예제 #1
0
 /**
  * Asks user what the path to Php source is.
  */
 public function configure()
 {
     $default = $this->settings->getDefaultValueFor('enablePhpTools', true);
     $this->settings['enablePhpTools'] = $this->dialog->askConfirmation($this->output, "\nDo you want to install the QA tools for PHP?", $default);
     if ($this->settings['enablePhpTools']) {
         $this->output->writeln("\n<info>Configuring PHP inspections</info>\n");
     }
 }
 public function configure()
 {
     if (!$this->settings['enablePhpTools']) {
         $this->settings['enableComposer'] = false;
         return false;
     }
     $this->settings['enableComposer'] = $this->dialog->askConfirmation($this->output, "Do you want to run `./composer.phar install` on every commit?", $this->settings->getDefaultValueFor('enableComposer', false));
 }
 /**
  * Asks user if they want to configure Behat.
  */
 public function configure()
 {
     $default = $this->settings->getDefaultValueFor('enableBehat', true);
     $this->settings['enableBehat'] = $this->dialog->askConfirmation($this->output, "\nDo you want to install the Behat framework?", $default);
     if ($this->settings['enableBehat']) {
         $this->settings['featuresDir'] = $this->settings->getBaseDir() . '/features';
     }
 }
 public function configure()
 {
     if (!$this->settings['enablePhpTools']) {
         $this->settings['enablePhpSecurityChecker'] = false;
         return false;
     }
     $default = $this->settings->getDefaultValueFor('enablePhpSecurityChecker', true);
     $this->settings['enablePhpSecurityChecker'] = $this->dialog->askConfirmation($this->output, "Do you want to enable the Sensiolabs Security Checker?", $default);
 }
 /**
  *
  */
 public function configure()
 {
     if (!$this->settings['enablePhpTools']) {
         $this->settings['enablePhpLint'] = false;
         return false;
     }
     $default = $this->settings->getDefaultValueFor('enablePhpLint', true);
     $this->settings['enablePhpLint'] = $this->dialog->askConfirmation($this->output, "Do you want to enable PHP Lint?", $default);
 }
 public function configure()
 {
     if (!$this->settings['enablePhpTools']) {
         $this->settings['enablePhpMessDetector'] = false;
         return false;
     }
     $default = $this->settings->getDefaultValueFor('enablePhpMessDetector', true);
     $this->settings['enablePhpMessDetector'] = $this->dialog->askConfirmation($this->output, "Do you want to enable the PHP Mess Detector?", $default);
     // Exclude default patterns
     $default = $this->settings->getDefaultValueFor('phpMdExcludePatterns', array());
     $excludePatterns = $this->multiplePathHelper->askPatterns("  - Which patterns should be excluded for PHP Mess Detector?", implode(',', $default), "  - Do you want to exclude custom patterns for PHP Mess Detector?", !empty($default));
     $this->settings['phpMdExcludePatterns'] = $excludePatterns;
 }
 public function testAskConfirmation()
 {
     $dialog = new DialogHelper();
     $dialog->setInputStream($this->getInputStream("\n\n"));
     $this->assertTrue($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?'));
     $this->assertFalse($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', false));
     $dialog->setInputStream($this->getInputStream("y\nyes\n"));
     $this->assertTrue($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', false));
     $this->assertTrue($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', false));
     $dialog->setInputStream($this->getInputStream("n\nno\n"));
     $this->assertFalse($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', true));
     $this->assertFalse($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', true));
 }
 public function configure()
 {
     if (!$this->settings['enablePhpTools']) {
         $this->settings['enablePhpCopyPasteDetection'] = false;
         return;
     }
     $default = $this->settings->getDefaultValueFor('enablePhpCopyPasteDetection', false);
     $this->settings['enablePhpCopyPasteDetection'] = $this->dialog->askConfirmation($this->output, "Do you want to enable PHP Copy Paste Detection?", $default);
     if (!$this->settings['enablePhpCopyPasteDetection']) {
         return;
     }
     // Tests is the Symfony default
     $default = $this->settings->getDefaultValueFor('phpCpdExcludePatterns', 'Tests');
     $this->settings['phpCpdExcludePatterns'] = $this->multiplePathHelper->askPatterns(" - Which patterns should be excluded for PHP Copy Paste detection?", $default, " - Do you want to exclude patterns for PHP Copy Paste detection?");
 }
 public function configure()
 {
     if (!$this->settings['enableJsTools']) {
         $this->settings['enableJsHint'] = false;
         return;
     }
     $default = $this->settings->getDefaultValueFor('enableJsHint', true);
     $this->settings['enableJsHint'] = $this->dialog->askConfirmation($this->output, "Do you want to enable JSHint?", $default);
     if ($this->settings['enableJsHint'] === false) {
         return;
     }
     $statusCode = $this->installJsHintCommand->run($this->input, $this->output);
     if ($statusCode) {
         $this->settings['enableJsHint'] = false;
     }
 }
예제 #10
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     # get the di container
     $project = $this->getApplication()->getProject();
     # verify if a output file name been passed
     if (($out_file_name = $input->getArgument('out')) === null) {
         $out_file_name = 'schema.xml';
     } else {
         $out_file_name = rtrim($out_file_name, '.xml') . '.xml';
     }
     # load the schema analyser
     $schema_analyser = $project->getSchemaAnalyser();
     #run the analyser
     $schema = $schema_analyser->analyse($project->getDatabase(), $project->getXMLEngineBuilder());
     # write the scheam file to the project folder (sources)
     $sources_io = $project->getSourceIO();
     $formatted_xml = $schema_analyser->format($schema->toXml());
     try {
         #Write config file to the project
         $sources_io->write($out_file_name, '', $formatted_xml, $overrite = false);
         $output->writeLn('<comment>++</comment> <info>sources/' . $out_file_name . '</info>');
     } catch (FileExistException $e) {
         #ask if they want to overrite
         $dialog = new DialogHelper();
         $answer = $dialog->askConfirmation($output, "<question>{$out_file_name} already exists do you want to Overrite? [y|n]</question>:", false);
         if ($answer) {
             #Write config file to the project
             $sources_io->write($out_file_name, '', $formatted_xml, $overrite = true);
             $output->writeLn('<comment>++</comment> <info>sources/' . $out_file_name . '</info>');
         }
     }
 }
예제 #11
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $dialog = new DialogHelper();
     if (!$input->getOption('silent')) {
         $confirmed = $dialog->askConfirmation($output, "This will install all TestGuy dependencies through PEAR installer.\n" . "PHPUnit, Symfony Components, and Mink will be installed.\n" . "Make shure this script has permission to install PEAR packages.\n" . "Do you want to proceed? (Y/n)");
         if (!$confirmed) {
             return;
         }
     }
     $output->writeln('Intalling PHPUnit...');
     $output->write(shell_exec('pear config-set auto_discover 1'));
     $output->write(shell_exec('pear install --alldeps pear.phpunit.de/PHPUnit'));
     $output->writeln("Installing Symfony Components...");
     $output->write(shell_exec("pear channel-discover pear.symfony.com"));
     $output->write(shell_exec('pear install symfony2/Finder'));
     $output->write(shell_exec('pear install symfony2/Process'));
     $output->write(shell_exec('pear install symfony2/CssSelector'));
     $output->write(shell_exec('pear install symfony2/DomCrawler'));
     $output->write(shell_exec('pear install symfony2/BrowserKit'));
     $output->writeln("Installing Mink...");
     $output->write(shell_exec("pear channel-discover pear.behat.org"));
     $output->write(shell_exec("pear install behat/mink"));
     $output->writeln('Please check PHPUnit was installed sucessfully. Run the "phpunit" command. If it is not avaible try installing PHPUnit manually');
     $output->writeln("Installaction complete. Init your new TestGuy suite calling the 'init' command");
 }
예제 #12
0
 private function populateDatabase(OutputInterface $output)
 {
     // Check if database exist
     $stmt = $this->dbConnection->prepare('SHOW DATABASES LIKE ?');
     $stmt->bindValue(1, $this->dbName);
     $stmt->execute();
     if ($stmt->rowCount() > 0) {
         $output->writeln('<info>Waring, Database "' . $this->dbName . '" already exist!</info>');
         $confirmation = $this->dialog->askConfirmation($output, '<question>Do you want to drop it? [N]</question> ', false);
         // if user don't want to use it, reselect the database
         if ($confirmation === false) {
             $output->writeln('Okay, then please reselect database name');
             $this->selectDatabase($output);
             $this->populateDatabase($output);
             return;
         } else {
             // Delete database
             $output->writeln('<info>Delete database....</info>');
             $this->dbConnection->executeQuery('DROP DATABASE ' . $this->dbName);
         }
     }
     $output->writeln('<info>Create database "' . $this->dbName . '"...</info>');
     $this->dbConnection->executeQuery('CREATE DATABASE ' . $this->dbName . ' COLLATE utf8_general_ci');
     $output->writeln('<info>Select database "' . $this->dbName . '"...</info>');
     $this->dbConnection->executeQuery('USE ' . $this->dbName);
     $output->writeln('<info>Populating table....</info>');
     $this->dbConnection->executeQuery($this->tableQuery);
     $output->writeln('<info>Populating table SUCCESS!</info>');
 }
예제 #13
0
 /**
  * @param string $task
  * @param CompareService $service
  * @param OutputInterface $output
  * @param array $dbs
  * @param bool $loaded
  * @return array
  */
 protected function processTask($task, CompareService $service, OutputInterface $output, array $dbs, $loaded)
 {
     $queries = [];
     switch ($task) {
         case 'create':
             if ($this->interactive >= self::INTERACTION_LOW) {
                 $renames = $this->dialog->askConfirmation($output, '<question>Attempt to rename tables? - Default true if interactive + loaded dependencies, false in other cases</question>', $this->interactive && $loaded);
             } else {
                 $renames = false;
             }
             if ($renames && !$loaded) {
                 //inform the user, but let them shoot themselves in the foot regardless...
                 $output->writeln('<error>Renaming tables without checking relations between tables is dangerous!</error>');
             }
             $return = $service->getMissingTablesFor($dbs['base'], $dbs['target'], $renames);
             $output->writeln(sprintf('<info>Added %d new tables (%s)</info>', count($return['added']), implode(', ', array_keys($return['added']))));
             /** @var Table $table */
             foreach ($return['added'] as $table) {
                 $queries[] = $table->getDefinitionString();
             }
             if ($return['renames']) {
                 $process = $this->processRenames($return['renames'], $output);
                 /** @var Database $base */
                 $base = $dbs['base'];
                 $base->addMissingTables($process['add']);
                 foreach ($process['add'] as $table) {
                     $queries[] = $table->getDefinitionString();
                 }
                 foreach ($process['rename'] as $oldName => $table) {
                     $queries[] = $table->getRenameQuery();
                     $base->applyRename($table, $oldName);
                 }
             }
             break;
         case 'alter':
             $dropFields = false;
             $checkFks = false;
             if ($this->interactive) {
                 $dropFields = $this->dialog->askConfirmation($output, '<question>Drop fields not in target table? (default: false)</question>', $dropFields);
                 $checkFks = $this->dialog->askConfirmation($output, '<question>Check Foreign Key constraints? (default: false)</question>', $checkFks);
             }
             $queries = $service->compareTables($dbs['base'], $dbs['target'], $dropFields, $checkFks);
             break;
         case 'constraints':
             $output->writeln('<info>constraints task not implemented yet</info>');
             $queries[] = '';
             break;
         case 'drop':
             if (!$loaded) {
                 $output->writeln('<error>Cannot reliably drop tables if relational table links were not set up</error>');
                 $output->writeln('<comment>As a result, these drop statements might not work</comment>');
             }
             $queries = $service->dropRedundantTables($dbs['base'], $dbs['target']);
             break;
         default:
             $queries[] = '';
     }
     return $queries;
 }
예제 #14
0
 /**
  * @return bool
  */
 protected function shouldRemove()
 {
     $shouldRemove = $this->input->getOption('force');
     if (!$shouldRemove) {
         $shouldRemove = $this->dialog->askConfirmation($this->output, $this->getQuestion('Are you sure?', 'n'), false);
     }
     return $shouldRemove;
 }
예제 #15
0
파일: IO.php 프로젝트: franzliedke/phpspec
 /**
  * @param string $question
  * @param bool   $default
  *
  * @return Boolean
  */
 public function askConfirmation($question, $default = true)
 {
     $lines = array();
     $lines[] = '<question>' . str_repeat(' ', 70) . "</question>";
     foreach (explode("\n", wordwrap($question), 50) as $line) {
         $lines[] = '<question>  ' . str_pad($line, 68) . '</question>';
     }
     $lines[] = '<question>' . str_repeat(' ', 62) . '</question> <value>' . ($default ? '[Y/n]' : '[y/N]') . '</value> ';
     return $this->dialogHelper->askConfirmation($this->output, implode("\n", $lines), $default);
 }
예제 #16
0
 /**
  * Asks a confirmation to the user.
  *
  * The question will be asked until the user answers by nothing, yes, or no.
  *
  * @param OutputInterface $output   An Output instance
  * @param string|array    $question The question to ask
  * @param Boolean         $default  The default answer if the user enters nothing
  *
  * @return Boolean true if the user has confirmed, false otherwise
  */
 public function askConfirmation(OutputInterface $output, $question, $default = true)
 {
     $hint = $default ? ' [Y/n] ' : ' [y/N] ';
     if (is_string($question)) {
         $question = $question . $hint;
     } else {
         array_push($question, array_pop($question) . $hint);
     }
     return parent::askConfirmation($output, $question, $default);
 }
 /**
  * Asks if the user wants to exclude some standard symfony paths
  *
  * @return array
  */
 protected function askExcludeSymfony()
 {
     $symfonyPatterns = array();
     $default = $this->settings->getDefaultValueFor('phpCsExcludeSymfony', false);
     $this->settings['phpCsExcludeSymfony'] = $this->dialog->askConfirmation($this->output, "  - Do you want to exclude some default Symfony patterns for PHP Code Sniffer?", $default);
     if ($this->settings['phpCsExcludeSymfony']) {
         $symfonyPatterns = array("src/*/*Bundle/Resources", "src/*/*Bundle/Tests", "src/*/Bundle/*Bundle/Resources", "src/*/Bundle/*Bundle/Tests");
     }
     return $symfonyPatterns;
 }
예제 #18
0
파일: Output.php 프로젝트: liip/rmt
 public function askConfirmation($text, InputInterface $input = null)
 {
     if ($this->dialogHelper instanceof QuestionHelper) {
         if (!$input) {
             throw new \InvalidArgumentException('With symfony 3, the input stream may not be null');
         }
         return $this->dialogHelper->ask($input, $this, new ConfirmationQuestion($text));
     }
     if ($this->dialogHelper instanceof DialogHelper) {
         return $this->dialogHelper->askConfirmation($this, $text);
     }
     throw new \RuntimeException("Invalid dialogHelper");
 }
예제 #19
0
 public function interact(DialogHelper $dialog, OutputInterface $output, array $answers)
 {
     #Database user Name
     $answers['username'] = $dialog->ask($output, '<question>What is the Database user name? [false] : </question>', false);
     #Database user Password
     $answers['password'] = $dialog->ask($output, '<question>What is the Database users password? [false] : </question>', false);
     if ($dialog->askConfirmation($output, '<question>Using in memory database? [y|n] : </question>', false)) {
         $answers['memory'] = ':memory';
     } else {
         #Database path
         $answers['path'] = $dialog->ask($output, '<question>What is the Database path relative to project root? : </question>', false);
     }
     return $answers;
 }
예제 #20
0
 /**
  * Truncate the Queue and Transition and Monitor Tables
  *
  * @param InputInterface $input An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dialog = new DialogHelper();
     $answer = $dialog->askConfirmation($output, '<info>Run Truncate</info> will <info>erase</info> stored jobs and transitions? [y|n] :', false);
     if ($answer) {
         $queue = $this->getHelper('queue')->getQueue();
         $db_config = $queue['config.database'];
         $doctrine = $queue['doctrine'];
         $output->writeln('Starting Truncate Database Tables');
         $doctrine->exec('TRUNCATE ' . $doctrine->getDatabase() . '.' . $db_config->getTransitionTableName());
         $doctrine->exec('TRUNCATE ' . $doctrine->getDatabase() . '.' . $db_config->getQueueTableName());
         $doctrine->exec('TRUNCATE ' . $doctrine->getDatabase() . '.' . $db_config->getMonitorTableName());
         $output->writeln('Finished Truncate Database Tables');
     }
 }
 /**
  * @param OutputInterface $output
  * @param Settings $settings
  * @return bool
  */
 protected function enablePhpUnitAutoLoad(OutputInterface $output, Settings $settings)
 {
     $default = $this->settings->getDefaultValueFor('enablePhpUnitAutoload', true);
     $settings['enablePhpUnitAutoload'] = $this->dialog->askConfirmation($output, "Do you want to enable an autoload script for PHPUnit?", $default);
     if (false === $settings['enablePhpUnitAutoload']) {
         return false;
     }
     if ($settings['enablePhpUnitAutoload']) {
         $default = $this->settings->getDefaultValueFor('phpUnitAutoloadPath', 'vendor/autoload.php');
         $settings['phpUnitAutoloadPath'] = $this->dialog->askAndValidate($output, "What is the path to the autoload script for PHPUnit? [{$default}] ", function ($data) use($settings) {
             if (file_exists($settings->getBaseDir() . '/' . $data)) {
                 return $data;
             }
             throw new \Exception("That path doesn't exist");
         }, false, $default);
     }
     return true;
 }
예제 #22
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln("<info>Starting setup of Ibuildings QA Tools<info>");
     // Test if correct ant version is installed
     $commandExistenceChecker = $this->getCommandExistenceChecker();
     if (!$commandExistenceChecker->commandExists('ant -version', $message, InstallCommand::MINIMAL_VERSION_ANT)) {
         $output->writeln("\n<error>{$message} -> Exiting.</error>");
         return;
     }
     if (!$this->dialog->askConfirmation($output, "\nIf you already have a build config, it will be overwritten. Do you want to continue?", true)) {
         return;
     }
     $output->writeln("\n");
     $this->configureProjectName($input, $output);
     // Register configurators
     $configuratorRegistry = $this->getConfiguratorRegistry();
     $configuratorRegistry->register(new BuildArtifactsConfigurator($output, $this->dialog, $this->settings));
     $configuratorRegistry->register(new TravisConfigurator($output, $this->dialog, $this->settings, $this->twig));
     // PHP
     $phpconfigurator = new PhpConfigurator($output, $this->settings);
     $this->requireHelper('dialog', $phpconfigurator);
     $configuratorRegistry->register($phpconfigurator);
     $configuratorRegistry->register(new PhpComposerConfigurator($output, $this->dialog, $this->settings));
     $configuratorRegistry->register(new PhpLintConfigurator($output, $this->dialog, $this->settings));
     $multiplePathHelper = new MultiplePathHelper($output, $this->dialog, $this->settings->getBaseDir());
     $configuratorRegistry->register(new PhpMessDetectorConfigurator($output, $this->dialog, $multiplePathHelper, $this->settings, $this->twig));
     $configuratorRegistry->register(new PhpCodeSnifferConfigurator($output, $this->dialog, $multiplePathHelper, $this->settings, $this->twig));
     $configuratorRegistry->register(new PhpCopyPasteDetectorConfigurator($output, $this->dialog, $multiplePathHelper, $this->settings));
     $configuratorRegistry->register(new PhpSecurityCheckerConfigurator($output, $this->dialog, $this->settings));
     $configuratorRegistry->register(new PhpSourcePathConfigurator($output, $this->dialog, $multiplePathHelper, $this->settings));
     $configuratorRegistry->register(new PhpUnitConfigurator($output, $this->dialog, $multiplePathHelper, $this->settings, $this->twig));
     // Javascript
     $configuratorRegistry->register(new JavascriptConfigurator($output, $this->dialog, $this->settings));
     $installJsHintCommand = $this->getApplication()->find('install:jshint');
     $configuratorRegistry->register(new JsHintConfigurator($input, $output, $this->dialog, $this->settings, $this->twig, $installJsHintCommand));
     $configuratorRegistry->register(new JavascriptSourcePathConfigurator($output, $this->dialog, $this->settings));
     // Functional testing
     $configuratorRegistry->register(new BehatConfigurator($output, $this->dialog, $this->settings, $this->twig));
     $configuratorRegistry->executeConfigurators();
     $this->writeAntBuildXml($input, $output);
     $command = $this->getApplication()->find('install:pre-commit');
     $command->run($input, $output);
     $this->settings['_qa_tools_run_completed'] = true;
 }
예제 #23
0
 /**
  * Sets up suite for a test.
  *
  * @param Environment $env
  * @param SpecificationIterator $iterator
  * @param Boolean $skip
  *
  * @return Setup
  */
 public function setUp(Environment $env, SpecificationIterator $iterator, $skip)
 {
     spl_autoload_register(function ($class) {
         $errorMessages = [$class . ' was not found.'];
         $formatter = new FormatterHelper();
         $formattedBlock = $formatter->formatBlock($errorMessages, 'error', true);
         $this->output->writeln('');
         $this->output->writeln($formattedBlock);
         $this->output->writeln('');
         $question = sprintf('Do you want to create a specification for %s? (Y/n)', $class);
         $questionBlock = $formatter->formatBlock($question, 'question', true);
         $dialog = new DialogHelper();
         if ($dialog->askConfirmation($this->output, $questionBlock, true)) {
             $this->output->writeln('');
             $this->specRunner->runDescCommand($class);
         }
     }, true, false);
     return $this->baseTester->setUp($env, $iterator, $skip);
 }
 /**
  * Ask the user for one or more paths/patterns
  *
  * @param string   $pathQuestion
  * @param string   $defaultPaths
  * @param null     $confirmationQuestion Optional question to ask if you want to set the value
  * @param bool     $defaultConfirmation
  * @param callable $callback
  *
  * @throws \Exception when callable is not callable.
  *
  * @return string
  */
 protected function ask($pathQuestion, $defaultPaths, $confirmationQuestion, $defaultConfirmation, $callback)
 {
     /**
      * Type hinting with callable (@see http://www.php.net/manual/en/language.types.callable.php)
      * is only from PHP5.4+ and therefore we check with is_callable()
      */
     if (!is_callable($callback)) {
         throw new \Exception('Error calling callable');
     }
     if ($defaultPaths) {
         $pathQuestion .= ' [' . (is_array($defaultPaths) ? implode(',', $defaultPaths) : $defaultPaths) . ']';
     }
     if ($confirmationQuestion) {
         if (!$this->dialog->askConfirmation($this->output, $confirmationQuestion, $defaultConfirmation)) {
             return array();
         }
     }
     return $this->dialog->askAndValidate($this->output, $pathQuestion . " (comma separated)\n", $callback, false, $defaultPaths);
 }
예제 #25
0
 public function interact(DialogHelper $dialog, OutputInterface $output, array $answers)
 {
     # Ask Database Schema Name
     $answers['schema'] = $dialog->ask($output, '<question>What is the Database schema name? : </question>');
     #Database user Name
     $answers['username'] = $dialog->ask($output, '<question>What is the Database user name? : </question>');
     #Database user Password
     $answers['password'] = $dialog->ask($output, '<question>What is the Database users password? : </question>');
     if ($dialog->askConfirmation($output, '<question>Using a unix socket? [y|n] :</question>', false)) {
         $answers['sock'] = $dialog->ask($output, '<question> Unix Socked path relative to project root? : </question>', false);
     } else {
         #Database host
         $answers['host'] = $dialog->ask($output, '<question>What is the Database host name? [localhost] : </question>', 'localhost');
         #Database port
         $answers['port'] = $dialog->ask($output, '<question>What is the Database port? [3306] : </question>', 3306);
     }
     #Database port
     $answers['charset'] = $dialog->ask($output, '<question>Connect with different character set? [false] : </question>', false);
     return $answers;
 }
예제 #26
0
 /**
  * Find and truncate/drop matched tables
  *
  * @param string $pattern
  * @param string $name
  * @param string $action
  *
  * @return void
  */
 protected function cleanMatch($pattern, $name, $action)
 {
     $tables = preg_grep($pattern, $this->tables);
     if (!count($tables)) {
         return;
     }
     array_walk($tables, array($this, 'prepareArrayForTableOutput'));
     if (!$this->force) {
         $this->output->writeln(sprintf('<info>%s</info> table(s):', $name));
         $table = new Table($this->output);
         $table->setRows($tables)->render();
         $confirm = $this->dialog->askConfirmation($this->output, sprintf('<question>%s table(s)?</question> ', ucfirst($action)), false);
         if (!$confirm) {
             return;
         }
     }
     foreach ($tables as $table) {
         $this->dbWrite->{$action . 'Table'}($table[0]);
         $this->output->writeln(sprintf('%s <info>%s</info>', ucfirst($action), $table[0]));
     }
 }
예제 #27
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $project = $this->getApplication()->getProject();
     $manager = $project['config_manager'];
     try {
         # get the CLI Config Driver
         $driver = $project->getConfigManager()->getCLIFactory()->create($this->answers['type']);
         $entity = $driver->merge(new Entity(), $this->answers);
         #Write config file to the project
         $manager->getWriter()->write($entity, $project->getConfigName());
     } catch (FileExistException $e) {
         #ask if they want to overrite
         $dialog = new DialogHelper();
         $answer = $dialog->askConfirmation($output, 'Config <info>Exists</info> do you want to <info>Overrite?</info> [y|n] :', false);
         if ($answer) {
             #Write config file to the project
             $manager->getWriter()->write($entity, $project->getConfigName(), true);
         }
     }
     # reload the config file (needed in shell mode)
     $project['config_file'];
     # tell them the file was written
     $output->writeln(sprintf("++ Writing <comment>config file</comment>  %s", $project->getConfigName()));
 }
예제 #28
0
 /**
  *
  * @param string $question        	
  * @param boolean $default        	
  * @return boolean
  */
 public function askConfirmation($question, $default = true)
 {
     return $this->dialogHelper->askConfirmation($this->output, $question, $default);
 }
예제 #29
0
 private function getDataPath(InputInterface $input, OutputInterface $output, DialogHelper $dialog)
 {
     $dataPath = $input->getOption('data-path');
     if (!$input->getOption('yes')) {
         $continue = $dialog->askConfirmation($output, 'Would you like to change default data-path ? (N/y)', false);
         if ($continue) {
             do {
                 $dataPath = $dialog->ask($output, 'Please provide the data path : ', null);
             } while (!$dataPath || !is_writable($dataPath));
         }
     }
     if (!$dataPath || !is_writable($dataPath)) {
         throw new \RuntimeException(sprintf('Data path `%s` is not writable', $dataPath));
     }
     return $dataPath;
 }
예제 #30
0
 /**
  * @inheritdoc
  */
 public function askConfirmation($question, $default = true)
 {
     return parent::askConfirmation($this->output, $this->formatQuestion($question, $default ? 'yes' : 'no'), $default);
 }