/** * Delete a file * This function is going to remove a file from your filesystem * * @param string $path * @return bool */ public static function delete($path) { $success = false; if (file_exists($path)) { $success = unlink($path); } if (static::_can_print()) { if ($success) { CCCli::line(CCCli::color('removed', 'green') . ' ' . $path); } else { CCCli::line(CCCli::color('removing failure', 'red') . ' ' . $path); } } return $success; }
/** * default help formatter * * @param array $params * @return void */ protected function help_formatter($help = null) { if (is_null($help)) { CCCli::line('Invalid data passed to help formatter.', 'red'); return; } $output = array(); // print the name if (isset($help['name'])) { $output[] = '+-' . str_repeat('-', strlen($help['name'])) . '-+'; $output[] = '| ' . CCCli::color($help['name'], 'light_yellow') . ' |'; $output[] = '+-' . str_repeat('-', strlen($help['name'])) . '-+'; } // description if (isset($help['desc'])) { $output[] = wordwrap(str_replace("\n", "\n" . ' * ', $help['desc']), 60); } // list the actions if (isset($help['actions']) && !empty($help['actions'])) { // for every action in this console controller foreach ($help['actions'] as $action => $attributes) { // print the action $output[] = ''; $output[] = '| ' . CCStr::suffix(get_called_class(), '\\') . '::' . CCCli::color($action, 'cyan'); $output[] = '|'; // for every attribute ( arguments, usage etc. ) foreach ($attributes as $attribute => $options) { $output[] = '| ' . CCCli::color(ucfirst($attribute), 'light_yellow'); // if we just got a string if (is_string($options)) { $output[] = '| ' . CCCli::color($options, 'green'); } elseif (is_array($options)) { // print every option and its description foreach ($options as $option => $description) { $buffer = CCCli::color($option, 'green'); $buffer .= str_repeat(' ', 35 - strlen($buffer)); $buffer .= $description; $buffer = '| ' . $buffer; // is the line to long? if (strlen($buffer) > 80) { $overflow = substr($buffer, 80); $buffer = substr($buffer, 0, 80) . "\n"; $overflow = wordwrap($overflow, 45); $overflow = explode("\n", $overflow); foreach ($overflow as $key => $value) { $overflow[$key] = '| ' . str_repeat(' ', 25) . trim($value); } $buffer .= implode("\n", $overflow); } $output[] = $buffer; } } $output[] = '|'; } array_pop($output); } } return $output; }