/usr/share/php/kohana3.1/system/classes/kohana/cli.php is in libkohana3.1-core-php 3.1.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | <?php defined('SYSPATH') or die('No direct script access.');
/**
* Helper functions for working in a command-line environment.
*
* @package Kohana
* @category Helpers
* @author Kohana Team
* @copyright (c) 2009-2011 Kohana Team
* @license http://kohanaframework.org/license
*/
class Kohana_CLI {
/**
* Returns one or more command-line options. Options are specified using
* standard CLI syntax:
*
* php index.php --username=john.smith --password=secret --var="some value with spaces"
*
* // Get the values of "username" and "password"
* $auth = CLI::options('username', 'password');
*
* @param string option name
* @param ...
* @return array
*/
public static function options($options)
{
// Get all of the requested options
$options = func_get_args();
// 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 option argument
continue;
}
// Remove the "--" prefix
$opt = substr($opt, 2);
if (strpos($opt, '='))
{
// Separate the name and value
list ($opt, $value) = explode('=', $opt, 2);
}
else
{
$value = NULL;
}
if (in_array($opt, $options))
{
// Set the given value
$values[$opt] = $value;
}
}
return $values;
}
} // End CLI
|