/** * Configure the console output with custom styles. */ protected function configureOutput() { $this->output = new ConsoleOutput(); $this->output->getFormatter()->setStyle('path', new OutputFormatterStyle('green', null, ['bold'])); $this->output->getFormatter()->setStyle('time', new OutputFormatterStyle('cyan', null, ['bold'])); $this->output->getFormatter()->setStyle('b', new OutputFormatterStyle(null, null, ['bold'])); }
public function run(InputInterface $input = null, OutputInterface $output = null) { if (null === $output) { $output = new ConsoleOutput(); } $output->getFormatter()->getStyle('info')->setForeground('magenta'); $output->getFormatter()->getStyle('comment')->setForeground('cyan'); return parent::run($input, $output); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $home = getenv('HOME'); if (!$home) { throw new \RuntimeException("'HOME' environment variable must be set for Cloud Drive to properly run."); } $this->configPath = rtrim($home, '/') . '/.cache/clouddrive-php/'; if (!file_exists($this->configPath)) { mkdir($this->configPath, 0777, true); } $this->configFile = "{$this->configPath}config.json"; $this->input = $input; $this->output = $output; // Set up basic styling $this->output->getFormatter()->setStyle('blue', new OutputFormatterStyle('blue')); $this->readConfig(); $this->main(); }
/** * Creates and initializes the SymfonyConsoleOutput instance * * @return void */ public function __construct() { $this->output = new SymfonyConsoleOutput(); $this->output->getFormatter()->setStyle('b', new OutputFormatterStyle(NULL, NULL, array('bold'))); $this->output->getFormatter()->setStyle('i', new OutputFormatterStyle('black', 'white')); $this->output->getFormatter()->setStyle('u', new OutputFormatterStyle(NULL, NULL, array('underscore'))); $this->output->getFormatter()->setStyle('em', new OutputFormatterStyle(NULL, NULL, array('reverse'))); $this->output->getFormatter()->setStyle('strike', new OutputFormatterStyle(NULL, NULL, array('conceal'))); $this->output->getFormatter()->setStyle('error', new OutputFormatterStyle('red')); $this->output->getFormatter()->setStyle('success', new OutputFormatterStyle('green')); }
/** * install * * @return void */ public static function install() { $output = new ConsoleOutput(); $style = new OutputFormatterStyle('green'); $output->getFormatter()->setStyle('green', $style); $assets = array('resources/cache', 'resources/log', 'web/assets'); foreach ($assets as $asset) { self::createAndChmod($asset, 0777); $output->writeln(sprintf('<green>Generating "%s" asset dir</green>', $asset)); } exec('php console assetic:dump'); }
/** * {@inheritdoc} */ public function index() { $style = new OutputFormatterStyle('red', 'yellow', array('bold', 'blink')); $output = new ConsoleOutput(); $output->getFormatter()->setStyle('fire', $style); $fileContents = $this->searchService->getFileContents(); foreach ($fileContents as $content) { $output->writeln('<info>Indexing File & Contents: </info><comment>' . $content['path'] . '</comment>'); /** * @var \Symfony\Component\Finder\SplFileInfo $file */ $this->createIndex($content['title'], $content['file_contents'], $content['path']); } }
/** * Creates and initializes the Symfony I/O instances * * @return void */ public function __construct() { $this->output = new SymfonyConsoleOutput(); $this->output->getFormatter()->setStyle('b', new OutputFormatterStyle(null, null, ['bold'])); $this->output->getFormatter()->setStyle('i', new OutputFormatterStyle('black', 'white')); $this->output->getFormatter()->setStyle('u', new OutputFormatterStyle(null, null, ['underscore'])); $this->output->getFormatter()->setStyle('em', new OutputFormatterStyle(null, null, ['reverse'])); $this->output->getFormatter()->setStyle('strike', new OutputFormatterStyle(null, null, ['conceal'])); }
public function handle(Args $args, IO $io, Command $command) { $output = new ConsoleOutput(); $style = new OutputFormatterStyle('white', 'black', array('bold')); if ($args->getArgument('package') == '') { $output->writeln(Cpm\message::USAGE); exit; } if (!file_exists('composer.json')) { $output->writeln(Cpm\message::NOComposerJSON); } $json = file_get_contents('composer.json'); $array = json_decode($json, TRUE); $datas = $array['require']; foreach ($datas as $data) { $output->getFormatter()->setStyle('bold', $style); $output->writeln('<bold>' . $data->name . '</>' . ' ' . $data->description); $output->writeln($data->keywords); } return 0; }
public function handle(Args $args, IO $io, Command $command) { $table = new Table(); $table->setHeaderRow(array('Name', 'Description')); $output = new ConsoleOutput(); $style = new OutputFormatterStyle('white', 'black', array('bold')); if ($args->getArgument('package') == '') { $output->writeln(Cpm\message::USAGE); exit; } $limit = $args->getOption('limit'); $limit_str = $limit ? 'limit ' . $limit : ''; $q = $args->getArgument('package'); $datas = R::findAll('repo', ' name LIKE ? order by download_monthly desc,favers desc,download_total desc' . $limit_str, ['%' . $q . '%']); foreach ($datas as $data) { $output->getFormatter()->setStyle('bold', $style); // $output->writeln('<bold>'.$data->name.'</>'.' '.$data->description); // $output->writeln($data->keywords); $table->addRow(array("(" . $data->favers . ")" . $data->name, $data->description)); } $table->render($io); return 0; }
<?php include 'vendor/autoload.php'; use RedBeanPHP\R; use Symfony\Component\Console\Formatter\OutputFormatterStyle; use Symfony\Component\Console\Output\ConsoleOutput; R::setup('sqlite:db/ppm.db'); $output = new ConsoleOutput(); $style = new OutputFormatterStyle('white', 'black', array('bold')); if (!isset($argv[1])) { $output->writeln(Cpm\message::USAGE); exit; } $q = $argv[1]; $datas = R::findAll('repo', ' name LIKE ? order by download_total desc', ['%' . $q . '%']); $a = array(); foreach ($datas as $data) { $output->getFormatter()->setStyle('bold', $style); $output->writeln('<bold>' . $data->name . '</bold>' . ' ' . $data->description); $output->writeln($data->keywords); }
public function testConstructor() { $output = new ConsoleOutput(Output::VERBOSITY_QUIET, true); $this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument'); $this->assertSame($output->getFormatter(), $output->getErrorOutput()->getFormatter(), '__construct() takes a formatter or null as the third argument'); }
/** * @return string */ protected function getPrompt() { // using the formatter here is required when using readline return $this->output->getFormatter()->format($this->application->getPrompt() . ' > '); }