Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php defined('SYSPATH') or die('No direct script access.');
- class Phostr_CLI extends Minion_CLI {
- public static function write_success($message, $foreground = NULL, $background = NULL)
- {
- $start = Phostr_CLI::color('SUCCESS:', 'white', 'green').' ';
- if ($foreground OR $background)
- {
- $message = Phostr_CLI::color($message, $foreground, $background);
- }
- Phostr_CLI::write($start.$message);
- }
- public static function write_warning($message, $foreground = NULL, $background = NULL)
- {
- $start = Phostr_CLI::color('WARNING:', 'white', 'yellow').' ';
- if ($foreground OR $background)
- {
- $message = Phostr_CLI::color($message, $foreground, $background);
- }
- Phostr_CLI::write($start.$message);
- }
- public static function write_error($message, $foreground = NULL, $background = NULL)
- {
- $start = Phostr_CLI::color('ERROR:', 'white', 'red').' ';
- if ($foreground OR $background)
- {
- $message = Phostr_CLI::color($message, $foreground, $background);
- }
- Phostr_CLI::write($start.$message);
- }
- public static function numbered_options($index = NULL)
- {
- // Found option values
- $values = array();
- // Skip the first option, it is always the file executed
- for ($i = 1; $i < $_SERVER['argc']; $i++)
- {
- if ( ! isset($_SERVER['argv'][$i]))
- {
- // No more args left
- break;
- }
- // Get the option
- $opt = $_SERVER['argv'][$i];
- if (substr($opt, 0, 2) == '--')
- {
- // This is not an numbered option argument
- continue;
- }
- // Set the given value
- $values[] = $opt;
- }
- if ($index === NULL)
- {
- return $values;
- }
- else
- {
- return $values[$index];
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement