mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 00:50:18 +01:00 
			
		
		
		
	[Nostromo] Commands for listing configuration
This commit is contained in:
		
							parent
							
								
									5e2cb0f9a7
								
							
						
					
					
						commit
						8d9d9addcc
					
				
							
								
								
									
										54
									
								
								src/Mage/Command/BuiltIn/Config/DumpCommand.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								src/Mage/Command/BuiltIn/Config/DumpCommand.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,54 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * This file is part of the Magallanes package.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * (c) Andrés Montañez <andres@andresmontanez.com>
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * For the full copyright and license information, please view the LICENSE
 | 
				
			||||||
 | 
					 * file that was distributed with this source code.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Mage\Command\BuiltIn\Config;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use Symfony\Component\Console\Input\InputInterface;
 | 
				
			||||||
 | 
					use Symfony\Component\Console\Output\OutputInterface;
 | 
				
			||||||
 | 
					use Mage\Command\AbstractCommand;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Command for Dumping the Configuration
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author Andrés Montañez <andresmontanez@gmail.com>
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					class DumpCommand extends AbstractCommand
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Configure the Command
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected function configure()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $this
 | 
				
			||||||
 | 
					            ->setName('config:dump')
 | 
				
			||||||
 | 
					            ->setDescription('Dumps the Magallanes configuration')
 | 
				
			||||||
 | 
					        ;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Execute the Command
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param InputInterface $input
 | 
				
			||||||
 | 
					     * @param OutputInterface $output
 | 
				
			||||||
 | 
					     * @return int|mixed
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected function execute(InputInterface $input, OutputInterface $output)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $output->writeln('Starting <fg=blue>Magallanes</>');
 | 
				
			||||||
 | 
					        $output->writeln('');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $output->writeln(sprintf('<comment>%s</comment>', var_export($this->runtime->getConfiguration(), true)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $output->writeln('');
 | 
				
			||||||
 | 
					        $output->writeln('Finished <fg=blue>Magallanes</>');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										69
									
								
								src/Mage/Command/BuiltIn/Config/EnvironmentsCommand.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								src/Mage/Command/BuiltIn/Config/EnvironmentsCommand.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,69 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * This file is part of the Magallanes package.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * (c) Andrés Montañez <andres@andresmontanez.com>
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * For the full copyright and license information, please view the LICENSE
 | 
				
			||||||
 | 
					 * file that was distributed with this source code.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Mage\Command\BuiltIn\Config;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use Symfony\Component\Console\Input\InputInterface;
 | 
				
			||||||
 | 
					use Symfony\Component\Console\Output\OutputInterface;
 | 
				
			||||||
 | 
					use Symfony\Component\Console\Helper\Table;
 | 
				
			||||||
 | 
					use Mage\Command\AbstractCommand;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Command for listing all the Environments
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author Andrés Montañez <andresmontanez@gmail.com>
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					class EnvironmentsCommand extends AbstractCommand
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Configure the Command
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected function configure()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $this
 | 
				
			||||||
 | 
					            ->setName('config:environments')
 | 
				
			||||||
 | 
					            ->setDescription('List all Magallanes configured Environments')
 | 
				
			||||||
 | 
					        ;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Execute the Command
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param InputInterface $input
 | 
				
			||||||
 | 
					     * @param OutputInterface $output
 | 
				
			||||||
 | 
					     * @return int|mixed
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected function execute(InputInterface $input, OutputInterface $output)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $output->writeln('Starting <fg=blue>Magallanes</>');
 | 
				
			||||||
 | 
					        $output->writeln('');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $table = new Table($output);
 | 
				
			||||||
 | 
					        $table->setHeaders(['Environment', 'Branch', 'User', 'Hosts']);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $configuration = $this->runtime->getConfigOptions('environments');
 | 
				
			||||||
 | 
					        foreach ($configuration as $environment => $config) {
 | 
				
			||||||
 | 
					            $row = [$environment];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $row[] = (isset($config['user']) ? $config['user'] : '-');
 | 
				
			||||||
 | 
					            $row[] = (isset($config['branch']) ? $config['branch'] : '-');
 | 
				
			||||||
 | 
					            $row[] = (isset($config['hosts']) ? implode(PHP_EOL, $config['hosts']) : '-');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $table->addRow($row);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $table->render();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $output->writeln('');
 | 
				
			||||||
 | 
					        $output->writeln('Finished <fg=blue>Magallanes</>');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user