Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.68 KB | None | 0 0
  1. <?php defined('SYSPATH') or die('No direct script access.');
  2.  
  3. class Phostr_CLI extends Minion_CLI {
  4.     public static function write_success($message, $foreground = NULL, $background = NULL)
  5.     {
  6.  
  7.         $start = Phostr_CLI::color('SUCCESS:', 'white', 'green').' ';
  8.  
  9.         if ($foreground OR $background)
  10.         {
  11.             $message = Phostr_CLI::color($message, $foreground, $background);
  12.         }
  13.  
  14.         Phostr_CLI::write($start.$message);
  15.     }
  16.  
  17.     public static function write_warning($message, $foreground = NULL, $background = NULL)
  18.     {
  19.  
  20.         $start = Phostr_CLI::color('WARNING:', 'white', 'yellow').' ';
  21.  
  22.         if ($foreground OR $background)
  23.         {
  24.             $message = Phostr_CLI::color($message, $foreground, $background);
  25.         }
  26.  
  27.         Phostr_CLI::write($start.$message);
  28.     }
  29.  
  30.     public static function write_error($message, $foreground = NULL, $background = NULL)
  31.     {
  32.  
  33.         $start = Phostr_CLI::color('ERROR:', 'white', 'red').' ';
  34.        
  35.         if ($foreground OR $background)
  36.         {
  37.             $message = Phostr_CLI::color($message, $foreground, $background);
  38.         }
  39.  
  40.         Phostr_CLI::write($start.$message);
  41.     }
  42.  
  43.     public static function numbered_options($index = NULL)
  44.     {
  45.         // Found option values
  46.         $values = array();
  47.  
  48.         // Skip the first option, it is always the file executed
  49.         for ($i = 1; $i < $_SERVER['argc']; $i++)
  50.         {
  51.             if ( ! isset($_SERVER['argv'][$i]))
  52.             {
  53.                 // No more args left
  54.                 break;
  55.             }
  56.  
  57.             // Get the option
  58.             $opt = $_SERVER['argv'][$i];
  59.  
  60.             if (substr($opt, 0, 2) == '--')
  61.             {
  62.                 // This is not an numbered option argument
  63.                 continue;
  64.             }
  65.  
  66.             // Set the given value
  67.             $values[] = $opt;
  68.         }
  69.  
  70.         if ($index === NULL)
  71.         {
  72.             return $values;
  73.         }
  74.         else
  75.         {
  76.             return $values[$index];
  77.         }
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement