示例#1
0
 /**
  * Create a new instance of the command.
  *
  * @param Application $app The application instance
  */
 public function __construct(Application $app)
 {
     $this->args = $app->args;
     $this->scope = isset($this->args[0]) ? array_shift($this->args) : '';
     if ($this->scope === 'help') {
         Help::execute($app);
         exit;
     }
 }
示例#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));
         }
     }
 }
示例#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;
 }
示例#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);
 }