Esempio n. 1
0
$temp = [];
foreach (MangaSourceList::getInstance()->getAllowedSourceList() as $src_key => $src_data) {
    $temp[] = Console::text($src_key, 0, ConsoleColors::COLOR_CYAN, true);
}
$blockText .= join(', ', $temp);
Console::writeMultiline($blockText, MANGA_SCRAPPER_TAB_STR . $emptyPaddedStr, '', true);
# ====================================================================
# By: anjan @ Nov 06, 2015 12:15 PM
# ====================================================================
# --url
# ====================================================================
Console::text(__pad_space_right("--url", $paramPadLength), 1);
$blockText = 'Accepts an url to manga chapters list or a specific chapter. If a valid manga chapter list url is specified, then the source, and slug param is ignored. Also, if the url is for a chapter, in addition to source and slug, action and chapter-ids params are ignored as well.';
Console::writeMultiline($blockText, MANGA_SCRAPPER_TAB_STR . $emptyPaddedStr, '', true);
/*********************************************************************
 * By: Anjan @ Nov 06, 2015 5:13 PM
 *********************************************************************
 * Available actions
 *********************************************************************/
Console::emptyLines(1);
consoleLinePurple('List of supported actions -', 2);
$actionKeyLengths = array();
foreach (ArgumentsList::getActionList() as $key => $data) {
    $actionKeyLengths[] = strlen($key);
}
$maxkeyLen = max($actionKeyLengths) + 2 * strlen(MANGA_SCRAPPER_TAB_STR);
foreach (ArgumentsList::getActionList() as $key => $data) {
    Console::text(__pad_space_right(MANGA_SCRAPPER_TAB_STR . $key . MANGA_SCRAPPER_TAB_STR, $maxkeyLen), 0, ConsoleColors::COLOR_CYAN);
    Console::writeMultiline($data['desc'] . ($data['default'] ? Console::text(' [default]', 0, ConsoleColors::COLOR_RED, true) : ''), __pad_space_right('', $maxkeyLen), '', true);
}
Console::emptyLines(1);
Esempio n. 2
0
 /**
  * Print the text
  *
  * @param string               $text  The text to print
  * @param string|array|boolean $color The color or options for display
  * @param bool|string          $auto_br
  */
 public static function log($text, $color = null, $auto_br = true)
 {
     echo Console::text($text, $color, $auto_br);
 }
Esempio n. 3
0
 /**
  * Register or run error
  *
  * @param string   $type
  * @param callable $route
  * @throws \InvalidArgumentException
  * @throws \Exception
  */
 public function handleError($type, $route = null)
 {
     if (!isset($this->injectors['errors'][$type])) {
         throw new \InvalidArgumentException('Unknown error type "' . $type . '" to call');
     }
     if (is_string($route) && class_exists($route) || $route instanceof \Closure) {
         // Set error handle
         $this->injectors['errors'][$type][2] = $route;
     } else {
         if (!$this->injectors['exception'] && $route instanceof \Exception) {
             // Not handle exception and throw it
             throw $route;
         } else {
             // Clean the output buffer
             ob_get_level() && ob_clean();
             // Check handle route and run it
             if (empty($this->injectors['errors'][$type][2]) || !$this->router->run($this->injectors['errors'][$type][2], array('error' => array('type' => $type, 'error' => $route, 'message' => $this->injectors['errors'][$type])))) {
                 /**
                  * Get error information
                  */
                 $error = $route instanceof \Exception ? $route : null;
                 $title = $error ? $error->getMessage() : $this->injectors['errors'][$type][1];
                 $code = $this->injectors['errors'][$type][0];
                 $message = $route ? $error ? $error->getFile() . ' [' . $error->getLine() . ']' : (string) $route : '';
                 if ($this->injectors['cli']) {
                     // Cli error show
                     $this->halt($code, Console::text('[' . $title . '] ' . ($message ? $message : '"' . $this->input->path() . '"') . ' ', 'redbg') . "\n" . ($this->injectors['debug'] && $error ? Console::text("\n[Error]\n", "yellow") . $error . "\n" : ''));
                 } else {
                     // Http error show
                     $this->output->status($this->injectors['errors'][$type][0]);
                     if ($this->injectors['debug']) {
                         // Debug error show
                         $this->renderView('Error', array('title' => $title, 'message' => $message ? $message : 'Could not ' . $this->input->method() . ' ' . $this->input->path(), 'stacks' => $this->injectors['debug'] && $error ? $error->getTraceAsString() : null));
                     } else {
                         // Normal error show
                         $this->renderView('Error', array('title' => $title, 'message' => $message ? $message : 'Could not ' . $this->input->method() . ' ' . $this->input->path()));
                     }
                     $this->stop();
                 }
             }
         }
     }
 }