Exemplo n.º 1
0
 public static function input($arguments)
 {
     if (!defined("STDIN")) {
         define("STDIN", fopen('php://stdin', 'r'));
     }
     $_argv = array();
     $_argv['command'] = null;
     $_argv['args'] = array();
     $_argv['options'] = array();
     $i = 0;
     foreach ($arguments as $k => $v) {
         $v = strtolower($v);
         if (substr($v, 0, 2) == '--') {
             $_argv['options'][] = $v;
         } else {
             if ($i == 1) {
                 $_argv['command'] = $v;
             }
             if ($i > 1) {
                 $_argv['args'][] = $v;
             }
         }
         $i++;
     }
     $command = $_argv['command'];
     $method = 'help';
     if (strpos($command, ':') !== false) {
         list($command, $method) = explode(':', $command);
     }
     static::$command = $command;
     static::$method = $method;
     static::$arguments = $_argv['args'];
     static::$options = $_argv['options'];
     return $_argv;
 }
Exemplo n.º 2
0
 public static function exec($command = null, $codepage = 1252)
 {
     static::$output = static::$errcode = null;
     exec(static::$command = 'chcp ' . $codepage . ' > nul & ' . $command, static::$output, static::$errcode);
     static::$output = implode(PHP_EOL, array_filter(static::$output));
     return static::$errcode;
 }