Example #1
0
 /**
  * Executes this application.
  *
  * @param bool $interactive runs in an interactive shell if true.
  *
  * @return void
  */
 public function run($interactive = false)
 {
     $app = $this['console'];
     if ($interactive) {
         $app = new Console\Shell($app);
     }
     $app->run();
 }
Example #2
0
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     if (true === $input->hasParameterOption(array('--shell', '-s'))) {
         $shell = new Shell($this);
         $shell->setProcessIsolation($input->hasParameterOption(array('--process-isolation')));
         $shell->run();
         return 0;
     }
     return parent::doRun($input, $output);
 }
Example #3
0
 /**
  * Runs the current application.
  *
  * @param InputInterface  $input  An Input instance
  * @param OutputInterface $output An Output instance
  *
  * @return integer 0 if everything went fine, or an error code
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     $output->writeLn($this->getHeader());
     $name = $this->getCommandName($input);
     if (true === $input->hasParameterOption(array('--shell', '-s'))) {
         $shell = new Shell($this);
         $shell->run();
         return 0;
     }
     if (true === $input->hasParameterOption(array('--ansi'))) {
         $output->setDecorated(true);
     } elseif (true === $input->hasParameterOption(array('--no-ansi'))) {
         $output->setDecorated(false);
     }
     if (true === $input->hasParameterOption(array('--help', '-h'))) {
         if (!$name) {
             $name = 'help';
             $input = new ArrayInput(array('command' => 'help'));
         } else {
             $this->wantHelps = true;
         }
     }
     if (true === $input->hasParameterOption(array('--no-interaction', '-n'))) {
         $input->setInteractive(false);
     }
     if (function_exists('posix_isatty') && $this->getHelperSet()->has('dialog')) {
         $inputStream = $this->getHelperSet()->get('dialog')->getInputStream();
         if (!posix_isatty($inputStream)) {
             $input->setInteractive(false);
         }
     }
     if (true === $input->hasParameterOption(array('--quiet', '-q'))) {
         $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
     } elseif (true === $input->hasParameterOption(array('--verbose', '-v'))) {
         $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
     }
     if (true === $input->hasParameterOption(array('--version', '-V'))) {
         $output->writeln($this->getLongVersion());
         return 0;
     }
     if (!$name) {
         $name = 'list';
         $input = new ArrayInput(array('command' => 'list'));
     }
     // the command name MUST be the first element of the input
     $command = $this->find($name);
     $this->runningCommand = $command;
     $statusCode = $command->run($input, $output);
     $this->runningCommand = null;
     # write Footer
     $output->writeLn($this->getFooter());
     return is_numeric($statusCode) ? $statusCode : 0;
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     // Run a shell if the --shell (or -s) option is set and if no command name is specified
     // Also, we do not want to have the --shell option available if we are already in a shell
     if (!$this->in_shell && $this->getCommandName($input) === null && $input->hasParameterOption(array('--shell', '-s'))) {
         $shell = new Shell($this);
         $this->in_shell = true;
         $shell->run();
         return 0;
     }
     return parent::doRun($input, $output);
 }
Example #5
0
    /**
     * Returns the shell header.
     *
     * @return string The header string
     */
    protected function getHeader()
    {
        return <<<EOF
<fg=blue>
                    /`
                    +o/`
                   -oooo/.
                  .+oooooo/-
                ./oooooo+//::`
            `.:+ooooo/-`
         .:+ooooooo+.     `...`
      ./+ooooooooo/    ./oooooo+-
    -+ooooooooooo+`   -oooooooooo/    `
  `/ooooooooooooo/    +ooooooooooo.   .+.
 `+oooooooooooooo+    /ooooooooooo.   -oo/`
 +oooooooooooooooo-   `/oooooooo+.    +ooo+`
:oooooooooooooooo+/`    `-////:.    `+ooooo+`
+oooooooooooo+:.`                 `:+ooooooo:
ooooooooooo/`                  .:+oooooooooo+
ooooooooo+`      `.-::--`       :oooooooooooo
/ooooooo/      -+oooooooo+:`     -oooooooooo+
.oooooo+`    `+oooooooooooo+.     /ooooooooo-
 :ooooo:     /oooooooooooooo+`    .oooooooo/
  /oooo-     +ooooooooooooooo.    `ooooooo/
   :ooo:     :oooooooooooooo+     .oooooo:
    `/oo`     :oooooooooooo+`     /oooo/.
      ./+`     .:+ooooooo/-      :ooo/.
        `-`       `.....       `/o/-`
                             `-:.`
</fg=blue>
EOF
 . parent::getHeader();
    }
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     $this->kernel->boot();
     if (!$this->registered) {
         $this->registerCommands();
         $this->registered = true;
     }
     foreach ($this->all() as $command) {
         if ($command instanceof ContainerAwareInterface) {
             $command->setContainer($this->container);
         }
     }
     if (true === $input->hasParameterOption(array('--shell', '-s'))) {
         $shell = new Shell($this);
         $shell->setProcessIsolation($input->hasParameterOption(array('--process-isolation')));
         $shell->run();
         return 0;
     }
     return parent::doRun($input, $output);
 }
Example #7
0
    /**
     * Returns the shell header.
     *
     * @return string The header string
     */
    protected function getHeader()
    {
        return <<<EOF
<logo>
             _   _            _
            | \\ | | ___ _ __ | |_ _   _ _ __   ___
 _____ _____|  \\| |/ _ \\ '_ \\| __| | | | '_ \\ / _ \\_____ _____
|_____|_____| |\\  |  __/ |_) | |_| |_| | | | |  __/_____|_____|
            |_| \\_|\\___| .__/ \\__|\\__,_|_| |_|\\___|
                       |_|
</logo>
EOF
 . parent::getHeader();
    }
Example #8
0
    /**
     * Returns the shell header.
     *
     * @return string The header string
     */
    protected function getHeader()
    {
        return <<<EOF
<info>
         _                                         _  _
     ___| |__   ___  _ ____      ____ _ _ __ ___  | || |
    / __| '_ \\ / _ \\| '_ \\ \\ /\\ / / _` | '__/ _ \\ | || |_
    \\__ \\ | | | (_) | |_) \\ V  V / (_| | | |  __/ |__   _|
    |___/_| |_|\\___/| .__/ \\_/\\_/ \\__,_|_|  \\___|    |_|
                    |_|
</info>
EOF
 . parent::getHeader();
    }
Example #9
0
    /**
     * Returns the shell header.
     *
     * @return string The header string
     */
    protected function getHeader()
    {
        return <<<EOF
<info>
           _____   _____ |_|
          / __  | /  __ | /|
         | |__| || |__| || |
         |  ___/ |  ___/ | |
         | |     | |     |_|
         |/      |/

</info>
EOF
 . parent::getHeader();
    }
Example #10
0
    /**
     * Returns the shell header.
     *
     * @return string The header string
     */
    protected function getHeader()
    {
        return <<<EOF
<info>
      _____                  __                    ___  
     / ____|                / _|                  |__ \\ 
    | (___  _   _ _ __ ___ | |_ ___  _ __  _   _     ) |
     \\___ \\| | | | '_ ` _ \\|  _/ _ \\| '_ \\| | | |   / / 
     ____) | |_| | | | | | | || (_) | | | | |_| |  / /_ 
    |_____/ \\__, |_| |_| |_|_| \\___/|_| |_|\\__, | |____|
             __/ |                          __/ |       
            |___/                          |___/        

</info>
EOF
 . parent::getHeader();
    }
Example #11
0
    /**
     * Returns the shell header.
     *
     * @return string The header string
     */
    protected function getHeader()
    {
        return <<<EOF
<info>

     #####                                ##     ##    ##      ##
   ##     ##                              ###    ##    ##      ##
   ##                                     ####   ##     ##    ##
   ##           ##     ##    ## #####     ## ##  ##      ##  ##
     #####      ##     ##    ###    ##    ##  ## ##       ####
          ##    ##     ##    ##     ##    ##   ####        ##
          ##    ##     ##    ##     ##    ##    ###        ##
   ##     ##    ##     ##    ##     ##    ##     ##        ##
     #####        #######    ##     ##    ##     ##        ##

   C  R  E  A  T  I  V  E     T  E  C  H  N  O  L  O  G  I  E  S

</info>
EOF
 . parent::getHeader();
    }
 /**
  * {@inheritdoc}
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     // Set the input to non-interactive if the yes or no options are used.
     if ($input->hasParameterOption(array('--yes', '-y')) || $input->hasParameterOption(array('--no', '-n'))) {
         $input->setInteractive(false);
     } elseif ($input->hasParameterOption(array('--shell', '-s'))) {
         $shell = new Shell($this);
         $shell->run();
         return 0;
     }
     return parent::doRun($input, $output);
 }
Example #13
0
 /**
  * Run the application and if no command is provided, use project:run.
  *
  * @param bool $interactive Whether to run in interactive mode.
  *
  * @return void
  */
 public function run($interactive = false)
 {
     /** @var ConsoleApplication $app  */
     $app = $this['console'];
     $app->setAutoExit(false);
     if ($interactive) {
         $app = new Shell($app);
     }
     $output = new Console\Output\Output();
     $output->setLogger($this['monolog']);
     $app->run(new ArgvInput(), $output);
 }
Example #14
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $shell = new Shell($this->getApplication());
     $shell->run();
 }
Example #15
0
 /**
  * Execute the Slic Application.
  *
  * @param bool $interactive Run this application interactively or not?
  */
 public function run($interactive = false)
 {
     $app = $this->container->get('console');
     if ($interactive) {
         $app = new Console\Shell($app);
     }
     $app->run();
 }
Example #16
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();
Example #17
0
 /**
  * Returns the shell header.
  *
  * @return string The header string
  */
 protected function getHeader()
 {
     $app = $this->getApplication();
     return '<info>' . $app::$logo . '</info>' . parent::getHeader();
 }