コード例 #1
0
 /**
  * Execute command.
  *
  * @param \Symfony\Component\Console\Input\InputInterface   $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('');
     $file = $this->utils->get('paths')->getConfigFileName();
     $filePath = ($input->getOption('path') ?: getcwd()) . '/' . $file;
     $dialog = $this->getHelperSet()->get('dialog');
     $configured = array();
     if (!file_exists($filePath)) {
         throw new Exception("No {$file} found at {$filePath}");
     }
     $output->writeln("<info>{$file} file found, configuring for " . ($input->getOption('env') ?: 'global') . " env...</info>");
     $output->writeln('');
     $config = json_decode(file_get_contents($filePath));
     $validator = new FormatValidator($config);
     if (!$validator->validate()) {
         throw new Exception("File invalid, with the following errors\n" . implode("\n", $validator->getErrors()));
     }
     $this->utils->get('paths')->setGeneratedConfigFilePrefix($input->getOption('env') ?: '');
     $configured = array();
     $genDir = $this->utils->get('paths')->getGeneratedConfigDir();
     $genFile = $this->utils->get('paths')->getGeneratedConfigFileName();
     foreach ($config as $key => $settings) {
         $configured[$key] = $dialog->ask($output, "    <comment>[{$key}] {$settings->description} :</comment> ", isset($settings->default) ? $settings->default : null);
         $output->writeln('');
     }
     file_put_contents("{$genDir}/{$genFile}", json_encode($configured));
     $output->writeln('<info>...configured!</info>');
     $output->writeln('');
 }
コード例 #2
0
 /**
  * @When /^I run the Show command$/
  */
 public function iRunTheShowCommand()
 {
     $pathUtil = new Paths();
     $pathUtil->setGeneratedConfigDir(dirname(__FILE__) . '/../../data');
     $manager = new Manager();
     $manager->register('paths', $pathUtil);
     $application = new Application();
     $application->add(new ShowCommand($manager));
     $command = $application->find('show');
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName(), '--env' => $this->env));
     $this->output = $commandTester->getDisplay();
 }
コード例 #3
0
 /**
  * Execute command.
  *
  * @param \Symfony\Component\Console\Input\InputInterface   $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('');
     $this->utils->get('paths')->setGeneratedConfigFilePrefix($input->getOption('env') ?: '');
     $file = $this->utils->get('paths')->getGeneratedConfigFileName();
     $filePath = $this->utils->get('paths')->getGeneratedConfigDir() . '/' . $file;
     $env = $input->getOption('env');
     if (!file_exists($filePath)) {
         throw new Exception(implode("\n", array('Generated config not found, try running:', '', '    quick-configure configure' . ($env ? " --env {$env}" : ''), '', 'to generate the config first')));
     }
     $config = json_decode(file_get_contents($filePath));
     foreach ($config as $key => $value) {
         $output->writeln("    <comment>" . $this->format($config, $key) . " :</comment> {$value}");
     }
     $output->writeln('');
 }
コード例 #4
0
 /**
  * Execute command.
  *
  * @param \Symfony\Component\Console\Input\InputInterface   $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->utils->get('paths')->setGeneratedConfigFilePrefix($input->getOption('env') ?: '');
     $file = $this->utils->get('paths')->getGeneratedConfigFileName();
     $filePath = $this->utils->get('paths')->getGeneratedConfigDir() . '/' . $file;
     $env = $input->getOption('env');
     $manager = new DumpManager();
     if (!file_exists($filePath)) {
         throw new Exception(implode("\n", array('Generated config not found, try running:', '', '    quick-configure configure' . ($env ? " --env {$env}" : ''), '', 'to generate the config first')));
     }
     $config = json_decode(file_get_contents($filePath));
     $dumper = $manager->get($input->getOption('format'));
     $dumped = $dumper->dump($config);
     if ($input->getOption('stdout')) {
         $output->writeln($dumped);
     } else {
         $outputFile = $input->getOption('path') . '/' . $input->getOption('name') . '.' . $dumper->getExtension();
         file_put_contents($outputFile, $dumped);
         $output->writeln('');
         $output->writeln("    <info>Config dumped to {$outputFile}</info>");
         $output->writeln('');
     }
 }
コード例 #5
0
 /**
  * Load config in the current environment.
  *
  * @return \QuickConfigure\Config
  */
 private function loadConfig()
 {
     $this->config = json_decode(file_get_contents($this->utils->get('paths')->getGeneratedConfigDir() . '/' . $this->utils->get('paths')->getGeneratedConfigFileName()));
     return $this;
 }