Example #1
0
 /**
  * Load the configuration from the given file
  *
  * @throws Exception
  * @return void
  */
 public static function load()
 {
     // look for a configuration file
     $configFilePath = self::$_configFile;
     // see if we have a config file option on the command line
     $path = \Usher\Lib\Console::getOption('configFilePath');
     if ($path !== null) {
         $configFilePath = $path;
     }
     if (is_file($configFilePath)) {
         self::$_currentConfig = self::$_wholeConfig = json_decode(file_get_contents($configFilePath));
         if (self::$_currentConfig == null) {
             throw new \Exception('Error parsing configuration file "' . self::$_configFile . '"!');
         }
         if (is_array(self::$_currentConfig)) {
             self::$_currentConfig = false;
             $project = \Usher\Lib\Console::getOption('selectedProject');
             if (!$project) {
                 throw new \Exception("No project was selected.");
             }
             foreach (self::$_wholeConfig as $conf) {
                 if ($conf->project->name == $project) {
                     self::$_currentConfig = $conf;
                     break;
                 }
             }
             if (!self::$_currentConfig) {
                 throw new \Exception("No project named {$project} in config file.");
             }
         }
     } else {
         throw new \Exception('No config file found!');
     }
 }
Example #2
0
 /**
  * Execute the Project Selection
  *
  * @param array $argumentData Argument data
  *
  * @return bool Stop/Don't stop execution
  */
 public function execute($argumentData)
 {
     if (count($argumentData) != 2) {
         throw new \RuntimeException('Project argument requires a project name.');
         return false;
     }
     \Usher\Lib\Console::setOption('selectedProject', $argumentData[1]);
     return true;
 }
Example #3
0
 /**
  * Write the line to the log file
  *
  * @param string $msg Line to write to file
  *
  * @return bool Write success/fail
  */
 public function write($msg)
 {
     // see if we have a custom log file
     $customLog = \Usher\Lib\Console::getOption('logFile');
     if ($customLog !== null) {
         self::$_logfile = $customLog;
     }
     // write to the file
     $ret = file_put_contents(self::$_logfile, $msg . "\n", FILE_APPEND);
     return $ret === false ? false : true;
 }
Example #4
0
 /**
  * Execute the Help option
  *
  * @param array $argumentData Argument data
  *
  * @return bool Stop/Don't stop execution
  */
 public function execute($argumentData)
 {
     // if the config file is valid set it
     $configFilePath = isset($argumentData[1]) ? $argumentData[1] : null;
     if ($configFilePath !== null && is_file($configFilePath)) {
         \Usher\Lib\Console::setOption('configFilePath', $configFilePath);
     } else {
         throw new \RuntimeException('Could not set configuration: "' . $configFilePath . '"');
     }
     return true;
 }
Example #5
0
 /**
  * Set up the autoloader with our new directory
  *
  * @param string $className Name of class to load
  *
  * @return void
  */
 public static function autoload($className)
 {
     $directory = \Usher\Lib\Console::getOption('customTaskDir');
     \Usher\Lib\Loader::autoload($className, $directory);
 }
Example #6
0
 /**
  * Execute the Help option
  *
  * @param array $argumentData Argument data
  *
  * @return bool Stop/Don't stop execution
  */
 public function execute($argumentData)
 {
     \Usher\Lib\Console::setOption('logFile', $argumentData[1]);
     return true;
 }
Example #7
0
 /**
  * Execute the Help option
  *
  * @param array $argumentData Argument data
  *
  * @return bool Stop/Don't stop execution
  */
 public function execute($argumentData)
 {
     \Usher\Lib\Console::setOption('runQuiet', true);
     return true;
 }