Пример #1
0
 /**
  * Class init.
  *
  * @param IOInterface $io
  * @param Registry    $config
  */
 public function __construct(IOInterface $io = null, Registry $config = null)
 {
     restore_error_handler();
     set_error_handler(array($this, 'error'));
     parent::__construct($io, $config);
     $this->registerCommands();
     $this->setDescription('Muse console application.');
     $this->rootCommand->addGlobalOption('p')->alias('path')->description('Dest path.');
     $this->rootCommand->addGlobalOption('t')->alias('tmpl')->defaultValue('default')->description('Sub template name.');
     if (defined('PHP_WINDOWS_VERSION_BUILD')) {
         $this->rootCommand->addGlobalOption('no-ansi', 1, 'Suppress ANSI colors on unsupported terminals.');
     }
     // Set basic dir.
     define('GENERATOR_PATH', $config['basic_dir.base'] ?: realpath(dirname(__DIR__) . '/../..'));
     $this->setHelp('');
 }
Пример #2
0
    /**
     * Class init.
     *
     * @param   IOInterface $io      The Input and output handler.
     * @param   Registry    $config  Application's config object.
     */
    public function __construct(IOInterface $io = null, \Windwalker\Registry\Registry $config = null)
    {
        $this->loadDispatcher();
        $io = $io ?: $this->getContainer()->get('input');
        // Make Windows no ANSI color
        if (defined('PHP_WINDOWS_VERSION_BUILD')) {
            $io->setOption('ansi', true);
        }
        parent::__construct($io, $config);
        $this->rootCommand->help(<<<HELP
Welcome to Windwalker Console.

HELP
);
        $descriptorHelper = $this->getDescriptor();
        $descriptorHelper->setOptionDescriptor(new OptionDescriptor())->setCommandDescriptor(new CommandDescriptor());
        $this->loadFirstlevelCommands();
    }