setDefaultCommand() публичный метод

Sets the default Command name.
public setDefaultCommand ( string $commandName, boolean $isSingleCommand = false ) : self
$commandName string The Command name
$isSingleCommand boolean Set to true if there is only one command in this application
Результат self
 /**
  * @return Application
  */
 public function create()
 {
     $app = new Application(Message::NAME, Message::VERSION);
     $app->setDefaultCommand(Message::COMMAND);
     $app->add($this->createAnalyzeCommand());
     return $app;
 }
Пример #2
0
 /**
  * Constructor
  */
 public function __construct($applicationDir)
 {
     // Init console application
     $this->consoleApplication = new ConsoleApplication();
     // Adding commands
     $commandNotificationSendCommand = new NotificationSendCommand($applicationDir);
     $this->consoleApplication->add($commandNotificationSendCommand);
     $this->consoleApplication->setDefaultCommand($commandNotificationSendCommand->getName());
 }
Пример #3
0
 /**
  * command应用主入口
  * @throws \Exception
  */
 static function main()
 {
     $application = new Application();
     $application->addCommands(self::createCommands());
     $application->setDefaultCommand(ThumbnailCommand::COMMAND_NAME);
     $application->run();
 }
Пример #4
0
 /**
  * command应用主入口
  * @throws \Exception
  */
 static function main()
 {
     $application = new Application();
     $application->addCommands(self::createCommands());
     $application->setDefaultCommand(self::DEFAULT_COMMAND_NAME);
     $application->run();
 }
Пример #5
0
function getApp() : Application
{
    $app = new Application();
    $app->add(new TestCommand());
    $app->setDefaultCommand('test');
    return $app;
}
Пример #6
0
 public function execute()
 {
     $console = new Application('');
     $def = new ListCommand();
     $console->add($def);
     $console->setDefaultCommand($def->getName());
     foreach ($this->path as $path) {
         $files = (new FileHandler($path))->readDir();
         foreach ($files as $file) {
             $command = basename($file, '.php');
             if ('BaseCommand' === $command) {
                 continue;
             }
             $console->add($this->fetchCommand($command));
         }
     }
     $output = new ConsoleOutput();
     self::warningText($output);
     self::errorText($output);
     $console->run(null, $output);
 }
Пример #7
0
 public function run()
 {
     $console = new Application(self::APP_NAME, self::APP_VERSION);
     $console->setDefaultCommand(self::APP_DEFAULT_COMMAND);
     $dispatcher = new EventDispatcher();
     $dispatcher->addListener(ConsoleEvents::COMMAND, function (ConsoleCommandEvent $event) {
         // get the input instance
         // $input = $event->getInput();
         // get the output instance
         $output = $event->getOutput();
         // get the command to be executed
         $command = $event->getCommand();
         // write something about the command
         //$output->writeln(sprintf('Before running command <info>%s</info>', $command->getName()));
         if ($command->getName() == StartServer::CLI_COMMAND) {
             $output->write(self::$BANNER);
         }
         // get the application
         // $application = $command->getApplication();
     });
     $console->setDispatcher($dispatcher);
     $console->addCommands([new Controller\StartServer(), new Controller\StopServer(), new Controller\ListServers(), new Controller\RegisterServer()]);
     $console->run();
 }
#!/usr/bin/env php
<?php 
/*
 * This file is part of the Certificationy CLI application.
 *
 * (c) Vincent Composieux <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require __DIR__ . '/vendor/autoload.php';
use Certificationy\Cli\Command\StartCommand;
use KevinGH\Amend\Command;
use KevinGH\Amend\Helper;
use Symfony\Component\Console\Application;
use Symfony\Component\Yaml\Yaml;
const VERSION = 1.4;
const APPLICATION_NAME = 'Certificationy';
$application = new Application(APPLICATION_NAME, VERSION);
$config = Yaml::parse(file_get_contents('config.yml'));
$updateCommand = new Command('self-update');
$updateCommand->setManifestUri($config['manifest_uri']);
$application->add($updateCommand);
$application->getHelperSet()->set(new Helper());
$startCommand = new StartCommand();
$application->add($startCommand);
$application->setDefaultCommand($startCommand->getName());
$application->run();
Пример #9
0
<?php

require_once __DIR__ . "/../vendor/autoload.php";
use Symfony\Component\Console\Application;
use jamesiarmes\PEWS\Generator\ConvertToPHP;
error_reporting(error_reporting() & ~E_NOTICE);
$cli = new Application('Convert XSD to PHP classes Command Line Interface', "2.0");
$cli->setCatchExceptions(true);
$cli->setDefaultCommand('convert:php');
$cli->addCommands(array(new ConvertToPHP()));
$cli->run();
Пример #10
0
<?php

require __DIR__ . '/vendor/autoload.php';
use SensioLabs\Deptrac\CompilerPass\CollectorPass;
use SensioLabs\Deptrac\CompilerPass\OutputFormatterPass;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Console\Application;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
if (!version_compare(phpversion(), "5.5.9", '>=')) {
    echo 'Required at least PHP version 5.5.9, your version: ' . PHP_VERSION . "\n";
    die(1);
}
(new XmlFileLoader($container = new ContainerBuilder(), new FileLocator(__DIR__)))->load(__DIR__ . '/services.xml');
$container->addCompilerPass(new OutputFormatterPass())->addCompilerPass(new CollectorPass())->compile();
$container->set('container', $container);
$application = new Application();
$application->add($container->get('command_init'));
$application->add($container->get('command_analyze'));
$application->add($container->get('command_self_update'));
$application->setDefaultCommand('analyze');
$application->run();
Пример #11
0
#!/usr/bin/env php
<?php 
if (version_compare(phpversion(), '5.4', '<')) {
    fwrite(STDERR, "PHP needs to be a minimum version of PHP 5.4\n");
    exit(1);
}
Phar::mapPhar('distill-cli.phar');
require_once 'phar://distill-cli.phar/vendor/autoload.php';
use Symfony\Component\Console\Application;
use Distill\Cli\Command as DistillCommand;
$appVersion = '1.0.4';
$app = new Application('Distill CLI', $appVersion);
$app->add(new DistillCommand\ExtractCommand($appVersion));
$app->add(new DistillCommand\AboutCommand($appVersion));
$app->add(new DistillCommand\SelfUpdateCommand($appVersion));
$app->setDefaultCommand('about');
$app->run();
__halt_compiler();
 Debug::enable(E_ALL, true);
 $container = \DG\App\loadContainer();
 $eventDispatcher = $container->get('event_dispatcher.traceable');
 $app = new Application();
 $app->add(new MakesCacheCommand($container));
 $app->add(new CssSelectorTestCommand());
 $app->add($reportCommand = new MakesCacheReportCommand());
 $app->add(new DomCrawlerTestCommand());
 $app->add(new DomCrawlerHHTestCommand());
 $app->add(new ExpressionLanguageCommand());
 $app->add(new LockHandlerTestCommand());
 $app->add(new IntlTestCommand());
 $app->add(new ModelsCommand($container));
 $app->add(new ProcessCommand());
 $app->add(new TestTimingAttackCommand());
 $app->setDefaultCommand($reportCommand->getName());
 $app->setDispatcher($eventDispatcher);
 $eventDispatcher->addListener(ConsoleEvents::COMMAND, function (ConsoleCommandEvent $event) use($reportCommand) {
     $output = $event->getOutput();
     $output->writeln("<info>Run command " . $event->getCommand()->getName() . "</info>");
     if ($event->getCommand() instanceof MakesCacheReportCommand) {
         $finder = new Finder();
         $makesCacheFilesCount = $finder->in(CACHE_PATH)->name('makes*.json')->count();
         if ($makesCacheFilesCount === 0 && $event->getCommand()->getName() === $reportCommand->getName()) {
             $output->writeln("<error>There is no cache files. Command execution stopped</error>");
             $event->disableCommand();
         }
     }
 });
 $eventDispatcher->addListener(ConsoleEvents::EXCEPTION, function (ConsoleExceptionEvent $event) {
     //wrap exception
Пример #13
0
#!/usr/bin/php
<?php 
// Require composer autoloader
require_once __DIR__ . '/vendor/autoload.php';
use Symfony\Component\Console;
// Create twitter service
$dataStore = new Ornithology\Service\DataStoreFile(getenv('HOME') . '/.ornithology');
$twitterService = new Ornithology\Service\Twitter($dataStore);
// Initialize the application
$application = new Console\Application('Ornithology', '0.0.3');
// Add application related commands
$application->add(new Ornithology\Command\Quit('exit'));
$application->add(new Ornithology\Command\Mark('mark'));
// Add twitter related commands
$application->add(new Ornithology\Command\Authorize('authorize', $twitterService));
$application->add(new Ornithology\Command\Refresh('refresh', $twitterService));
$application->add(new Ornithology\Command\Tweet('tweet', $twitterService));
$application->add(new Ornithology\Command\Reply('reply', $twitterService));
$application->add(new Ornithology\Command\Retweet('retweet', $twitterService));
$application->add(new Ornithology\Command\Favorite('favorite', $twitterService));
$application->add(new Ornithology\Command\Urls('urls', $twitterService));
// Set some defaults
$application->setDefaultCommand('mark');
// Run the application as a shell
$shell = new Console\Shell($application);
$shell->run();
Пример #14
0
<?php

/**
 * Created by Érick Carvalho on 17/12/2015.
 */
require 'vendor/autoload.php';
use Symfony\Component\Console\Application;
use WordFilter\Console\Commands\MainMenuCommand;
use WordFilter\Console\Commands\CorrectorCommand;
use WordFilter\Console\Commands\DictionaryManagerCommand;
$application = new Application('Word Filter', '1.0.1');
$application->add(new DictionaryManagerCommand());
$application->add(new CorrectorCommand());
$application->add(new MainMenuCommand());
$application->setDefaultCommand('menu');
$application->run();
Пример #15
0
#!/usr/bin/env php
<?php 
require_once './libraries/autoload.php';
use DedicatedManager\Setup\SetupCommand;
use Symfony\Component\Console\Application;
error_reporting(E_ALL & ~E_DEPRECATED & ~E_WARNING);
$application = new Application();
$application->add(new SetupCommand());
$application->setDefaultCommand('setup');
$application->run();
Пример #16
0
 public function testSetRunCustomSingleCommand()
 {
     $command = new \FooCommand();
     $application = new Application();
     $application->setAutoExit(false);
     $application->add($command);
     $application->setDefaultCommand($command->getName(), true);
     $tester = new ApplicationTester($application);
     $tester->run(array());
     $this->assertContains('called', $tester->getDisplay());
     $tester->run(array('--help' => true));
     $this->assertContains('The foo:bar command', $tester->getDisplay());
 }
Пример #17
0
 static function main()
 {
     $application = new Application();
     $command = new static();
     $application->add($command);
     $application->setDefaultCommand($command->getName());
     $application->run();
 }
Пример #18
0
 public function testSetRunCustomDefaultCommand()
 {
     $command = new \FooCommand();
     $application = new Application();
     $application->setAutoExit(false);
     $application->add($command);
     $application->setDefaultCommand($command->getName());
     $tester = new ApplicationTester($application);
     $tester->run(array());
     $this->assertEquals('interact called' . PHP_EOL . 'called' . PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
     $application = new CustomDefaultCommandApplication();
     $application->setAutoExit(false);
     $tester = new ApplicationTester($application);
     $tester->run(array());
     $this->assertEquals('interact called' . PHP_EOL . 'called' . PHP_EOL, $tester->getDisplay(), 'Application runs the default set command if different from \'list\' command');
 }
Пример #19
0
<?php

require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/Console/TestCommand.php';
require __DIR__ . '/Console/DefaultCommand.php';
use Symfony\Component\Console\Application;
$default = new \Console\DefaultCommand();
$app = new Application();
$app->add(new \Console\TestCommand());
$app->add($default);
$app->setDefaultCommand($default->getName());
$app->run();