Changed author of dispatch class and synopsis
[TYPO3CMS/Extensions/t3build.git] / dispatch.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009 AOE media GmbH <dev@aoemedia.de>
6 * All rights reserved
7 *
8 * This copyright notice MUST APPEAR in all copies of the script!
9 ***************************************************************/
10
11 if (!defined ('TYPO3_cliMode')) {
12 die('Access denied: CLI only.');
13 }
14
15 require_once PATH_t3lib . 'class.t3lib_cli.php';
16 require_once t3lib_extMgm::extPath('t3build').'classes/class.tx_t3build_providerInfo.php';
17
18 /**
19 * General CLI dispatcher for the t3build extension.
20 *
21 * @package t3build
22 * @author Christian Opitz <christian.opitz@netresearch.de>
23 */
24 class tx_t3build_dispatch extends t3lib_cli {
25 const ExtKey = 't3build';
26
27 /**
28 * @var tx_t3build_providerInfo
29 */
30 protected $providerInfo;
31
32 /**
33 * Creates this object.
34 */
35 public function __construct() {
36 parent::__construct();
37 $this->providerInfo = t3lib_div::makeInstance('tx_t3build_providerInfo');
38 $this->cli_help = array_merge($this->cli_help, array(
39 'name' => 'tx_t3build_dispatch',
40 'synopsis' => self::ExtKey . ' command [subcommand] ###OPTIONS###',
41 'description' => '',
42 'examples' => 'typo3/cli_dispatch.phpsh ' . self::ExtKey . ' database updateStructure',
43 'author' => '(c) 2013 Netresearch GmbH & Co.KG <typo3@netresearch.de>',
44 ));
45 }
46
47 /**
48 * Dispatches the requested actions to the accordant controller.
49 *
50 * @return void
51 */
52 public function dispatch() {
53 $provider = (string)$this->cli_args['_DEFAULT'][1];
54 $action = (string)$this->cli_args['_DEFAULT'][2];
55
56 if (isset($this->cli_args['--debug'])) {
57 restore_exception_handler();
58 restore_error_handler();
59 }
60
61 if (!$provider) {
62 $this->cli_echo('No command provided - please specify one of the following commands:'.PHP_EOL, true);
63 echo implode(PHP_EOL, $this->providerInfo->getProviders()).PHP_EOL;
64 return;
65 }
66
67 $instance = $this->providerInfo->getProviderInstance($provider);
68 $instance->init($this->cli_args);
69 $instance->run($action);
70 }
71 }
72
73 echo t3lib_div::makeInstance('tx_t3build_dispatch')->dispatch();