Exemple #1
0
 /**
  * Output a row within a table.
  *
  * @param array $columns The columns in the row
  */
 public static function tableRow(array $columns)
 {
     $output = [];
     foreach ($columns as $index => $value) {
         $output[] = str_pad(' ' . $value, static::$tableColumnLengths[$index]);
     }
     static::outputEnd(implode(ANSI::fg('|', ANSI::GRAY), $output));
 }
Exemple #2
0
 /**
  * Execute the command.
  *
  * @param Application $app The application instance
  *
  * @return mixed
  */
 public static function execute(Application $app)
 {
     $args = $app->args;
     if (!isset($args[0])) {
         $args[0] = 'all';
     }
     $scope = $args[0];
     if (!in_array($scope, ['all', 'assets', 'css', 'coffee', 'js', 'sass', 'help'])) {
         Prompt::outputend(ANSI::fg('The scope "' . $scope . '" could not be found.' . "\n", ANSI::RED));
         Help::execute($app);
         exit(127);
     }
     if ($scope === self::HELP) {
         Help::execute($app);
         exit;
     }
     $scopes = [];
     if ($scope === 'all') {
         $scopes = array_keys(Compiler::$classMap);
     }
     if ($scope === 'assets') {
         $scopes = ['css', 'coffee', 'js', 'sass'];
     }
     if (!is_array($scopes)) {
         $scopes = [$scopes];
     }
     foreach ($scopes as $scope) {
         $scopeClass = Compiler::$classMap[$scope];
         if ($scope === 'pages') {
             $msg = 'Compiling ' . ucwords($scope) . '...';
             Prompt::output(ANSI::fg(str_pad($msg, 22), ANSI::GRAY));
             $scopeClass::bootstrap();
             Prompt::outputend(ANSI::fg(' done', ANSI::GREEN));
             continue;
         }
         $config = $app->config->assets->{$scope};
         if ($config) {
             $config->clean = $app->config->assets->clean;
             $compiler = new $scopeClass($config);
             $msg = 'Compiling ' . ucwords($scope) . '...';
             Prompt::output(ANSI::fg(str_pad($msg, 22), ANSI::GRAY));
             $compiler->compile();
             Prompt::outputend(ANSI::fg(' done', ANSI::GREEN));
         }
     }
 }
Exemple #3
0
 public function test()
 {
     list($uri, $verb) = array_pad($this->args, 2, null);
     if (!$uri) {
         Prompt::outputend(ANSI::fg('You must specify a URI to test.' . "\n", ANSI::RED));
         return Help::execute(Application::instance());
     }
     if (!$verb) {
         $verb = 'GET';
     }
     $this->loadRoutes(strtoupper($verb));
     $_SERVER['REQUEST_URI'] = $uri;
     foreach (Router::routes() as $route) {
         if ($route->match()) {
             Prompt::tableHeader(['Verb' => 10, 'Route' => 35, 'Name' => 20]);
             return Prompt::tableRow([strtoupper($route->verb), $route->route, $route->name !== $route->route ? $route->name : ' ']);
         }
     }
     Prompt::outputend(ANSI::fg('Route for URI ' . $uri . ' could not be found.', ANSI::RED));
     exit;
 }
Exemple #4
0
 /**
  * Execute the command.
  */
 public function executeCommand()
 {
     $command = $this->command;
     $class = 'Pug\\Cli\\Command\\' . Str::camelCaps($command);
     if (!class_exists($class)) {
         Prompt::outputend(ANSI::fg('The command "' . $command . '" could not be found.' . "\n", ANSI::RED));
         $this->command = 'help';
         Help::execute($this);
         exit(127);
     }
     $class::execute($this);
 }