Mage/Console.php
/**
     * Runns a Magallanes Command
     * @throws Exception
     */
Runns a Magallanes Command
@throws Exception
Runns a Magallanes Command @throws Exception
public function run($arguments)
    {
    	register_shutdown_function(function() {
            if (error_get_last() !== null) {
            	if (file_exists('.mage/~working.lock')) {
            		unlink('.mage/~working.lock');
            	}
            }
    	});
        $configError = false;
        try {
            $config = new Config;
            $config->load($arguments);
            $configLoadedOk = true;
        } catch (Exception $exception) {
            $configError = $exception->getMessage();
        }
        $commandName = $config->getArgument(0);
        $showGrettings = true;
        if (in_array($commandName, array('install', 'upgrade', 'version'))) {
            self::$logEnabled = false;
            $showGrettings = false;
        } else {
            self::$logEnabled = $config->general('logging', false);
        }
        if ($showGrettings) {
            self::output('Starting <blue>Magallanes</blue>', 0, 2);
        }
        if ($configError !== false) {
            self::output('<red>' . $configError . '</red>', 1, 2);
        } else {
            try {
                $command = Command\Factory::get($commandName, $config);
                if ($command instanceOf Command\RequiresEnvironment) {
                    if ($config->getEnvironment() == false) {
                        throw new Exception('You must specify an environment for this command.');
                    }
                }
                $command->run();
            } catch (Exception $exception) {
                self::output('<red>' . $exception->getMessage() . '</red>', 1, 2);
            }
        }
        if ($showGrettings) {
            self::output('Finished <blue>Magallanes</blue>', 0, 2);
            if (file_exists('.mage/~working.lock')) {
            	unlink('.mage/~working.lock');
            }
        }
        self::checkLogs($config);
    }
public function run ( $ arguments ) { register_shutdown_function ( function ( ) { if ( error_get_last ( ) !== null ) { if ( file_exists ( '.mage/~working.lock' ) ) { unlink ( '.mage/~working.lock' ) ; } } } ) ; $ configError = false ; try { $ config = new Config ; $ config -> load ( $ arguments ) ; $ configLoadedOk = true ; } catch ( Exception $ exception ) { $ configError = $ exception -> getMessage ( ) ; } $ commandName = $ config -> getArgument ( 0 ) ; $ showGrettings = true ; if ( in_array ( $ commandName , array ( 'install' , 'upgrade' , 'version' ) ) ) { self :: $ logEnabled = false ; $ showGrettings = false ; } else { self :: $ logEnabled = $ config -> general ( 'logging' , false ) ; } if ( $ showGrettings ) { self :: output ( 'Starting <blue>Magallanes</blue>' , 0 , 2 ) ; } if ( $ configError !== false ) { self :: output ( '<red>' . $ configError . '</red>' , 1 , 2 ) ; } else { try { $ command = Command \ Factory :: get ( $ commandName , $ config ) ; if ( $ command instanceOf Command \ RequiresEnvironment ) { if ( $ config -> getEnvironment ( ) == false ) { throw new Exception ( 'You must specify an environment for this command.' ) ; } } $ command -> run ( ) ; } catch ( Exception $ exception ) { self :: output ( '<red>' . $ exception -> getMessage ( ) . '</red>' , 1 , 2 ) ; } } if ( $ showGrettings ) { self :: output ( 'Finished <blue>Magallanes</blue>' , 0 , 2 ) ; if ( file_exists ( '.mage/~working.lock' ) ) { unlink ( '.mage/~working.lock' ) ; } } self :: checkLogs ( $ config ) ; }
Runns a Magallanes Command
 @throws Exception
Runns a Magallanes Command @throws Exception
// Declare a Shutdown Closure // Only Unlock if there was an error // Load configuration // Load Config // Command Option // Logging // Grettings // Run Command - Check if there is a Configuration Error // Run Command and check for Command Requirements // Check if logs need to be deleted