~gnupo/gnupo/trunk

« back to all changes in this revision

Viewing changes to lib/GnupoParser/gnupo.cli.php

  • Committer: Miguel Trias
  • Date: 2009-09-08 20:26:12 UTC
  • Revision ID: miguel.trias@gmail.com-20090908202612-2yut0gmbney9znmh
Deleted versioned files that are cached maps (dependant of environment) that must not be versioned. Added a directory (/cache) to put temporary or cached files. Added Persistable interface. added unit-testing initialization script.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
        use \Gnupo\Cli\OutputController as OutputController;
11
11
 
12
12
        /**
13
 
         *
14
13
         * Main script to be runned from CLI environment
 
14
         * @todo Set, parse and interpret a Help Parameter
15
15
         */
16
16
        class Main
17
17
        {
18
18
 
 
19
                /**
 
20
                 * This method initializes all the runtime environment of the GnupoParser
 
21
                 * @todo Let configure maps caching path with a parameter
 
22
                 */
19
23
                public function initialize()
20
24
                {
21
 
                        require_once __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'Autoloading'.DIRECTORY_SEPARATOR.'Loader.class.php';
 
25
                        $basePath = realpath(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..').DIRECTORY_SEPARATOR;
 
26
                        require_once $basePath . 'lib'. DIRECTORY_SEPARATOR . 'Autoloading' . DIRECTORY_SEPARATOR . 'Loader.class.php';
22
27
                        $Loader = Loader::getInstance();
 
28
                        $Loader->setMapsCachingPath($basePath . 'cache' . DIRECTORY_SEPARATOR . 'autoload-maps-cache');
23
29
                        $Loader->setUseMapsCache(false);
24
 
                        $Loader->addPath(__DIR__.DIRECTORY_SEPARATOR.'..');
 
30
                        $Loader->addPath($basePath . 'lib');
25
31
                }
26
32
 
27
33
                private static $instance;
39
45
 
40
46
                public function execute()
41
47
                {
42
 
                        $Parameters = ArgumentParser::parse($_SERVER['argv']);
43
 
 
44
 
                        $ParameterHolder = new ParameterHolder($Parameters);
45
 
 
 
48
                        # Arguments Parsing
 
49
                        $ParametersArray = ArgumentParser::parse($_SERVER['argv']);
 
50
                        $ParameterHolder = new ParameterHolder($ParametersArray);
46
51
                        $ParameterHolder->printAll();
47
52
 
 
53
                        # Printer Instance (responsible of all the output)
48
54
                        $Printer = new Printer();
49
55
                        $Printer->out("Prueba", Printer::COLOR_G);
50
56
 
 
57
                        # Output Controller (responsible of all structured output)
51
58
                        $OutputController = OutputController::getInstance();
52
59
                        $OutputController->setMaxRelevancyLevel(OutputController::R_WARNING);
53
60
                        $OutputController->coloredMessage("Output from output controller",Printer::COLOR_R);