/** * @param string $message */ public function logError($message) { if ($this->userDir instanceof File\Directory) { date_default_timezone_set('UTC'); $logEntry = sprintf("%s %s\n", date('m/d/Y G:i:s'), $message); $this->userDir->child('error.log')->putContents($logEntry, true); } }
<?php use Huxtable\CLI\Command; use Huxtable\CLI\Input; use Huxtable\Core\File; /** * @command install * @desc Symlink executable to a convenient path * @usage install <dir> */ $commandInstall = new Command('install', 'Symlink executable to a convenient path', function ($dir) { try { $dirPath = new File\Directory($dir); if (!$dirPath->exists()) { throw new Exception("Directory '{$dir}' does not exist"); } } catch (Exception $e) { throw new Command\CommandInvokedException($e->getMessage(), 1); } $target = $dirPath->child('slack'); $source = $this->dirApp->childDir('bin')->child('slack'); if ($target->exists()) { throw new Command\CommandInvokedException("Invalid target: '{$target}' exists", 1); } $command = "ln -s {$source} {$target}"; exec($command); echo "Linked to '{$target}'" . PHP_EOL; }); return $commandInstall;