3 * Script for code generation
6 * @license http://www.gnu.org/licenses/agpl.html AGPL Version 3
7 * @author Flávio Gomes da Silva Lisboa <flavio.lisboa@serpro.gov.br>
8 * @copyright Copyright (c) 2014 Metaways Infosystems GmbH (http://www.metaways.de)
12 define('APPLICATION','Application');
21 $opts = new Zend_Console_Getopt(array(
22 'create application|a=s'=>'create application option with required string parameter',
23 'help'=>'help option with no required parameter'
27 } catch (Zend_Console_Getopt_Exception $e) {
28 echo $e->getUsageMessage();
32 if ($applicationName = $opts->getOption('a'))
34 echo create(APPLICATION, array($applicationName));
37 echo "UNEXPECTED ERROR: missing argument. Type tn -help to see parameters \n";
42 * Sets the include path and loads autoloader classes
44 function prepareEnvironment()
47 realpath(__DIR__ . '/../tine20'),
48 realpath(__DIR__ . '/../tine20/library'),
51 set_include_path(implode(PATH_SEPARATOR, $paths));
53 require_once realpath(__DIR__ . '/../tine20') . '/bootstrap.php';
57 * Creates an instance of a class that knows how to build the requested structure
58 * Command can executed from everywhere, because the path is determined by __DIR__
59 * @param string $builder
61 * @return string message
63 function create($builder, array $args)
65 // last argument is path of Tine 2.0
66 $args[] = realpath(__DIR__ . '/../tine20');
68 $className = 'Tool_CodeGenerator_' . $builder;
69 $tcg = new $className();
70 return $tcg->build($args);