2014-05-01 20:15:47 +02:00
|
|
|
<?php
|
|
|
|
|
2014-05-13 14:32:30 +02:00
|
|
|
namespace ManiaControl\Utils;
|
2014-05-01 20:15:47 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Command Line Helper Class
|
2014-05-02 17:40:47 +02:00
|
|
|
*
|
|
|
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
2016-05-04 09:57:31 +02:00
|
|
|
* @copyright 2014-2016 ManiaControl Team
|
2014-05-02 17:40:47 +02:00
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
2014-05-01 20:15:47 +02:00
|
|
|
*/
|
|
|
|
class CommandLineHelper {
|
|
|
|
|
|
|
|
/**
|
2014-08-02 20:51:48 +02:00
|
|
|
* Get the command line parameter value with the given name
|
2014-05-02 17:40:47 +02:00
|
|
|
*
|
2014-05-01 20:15:47 +02:00
|
|
|
* @param string $paramName
|
2014-06-26 11:07:53 +02:00
|
|
|
* @return string
|
2014-05-01 20:15:47 +02:00
|
|
|
*/
|
|
|
|
public static function getParameter($paramName) {
|
2014-05-02 17:40:47 +02:00
|
|
|
$paramName = (string)$paramName;
|
2014-08-02 20:51:48 +02:00
|
|
|
$params = self::getAllParameters();
|
|
|
|
foreach ($params as $param) {
|
|
|
|
$parts = explode('=', $param, 2);
|
2014-05-01 20:15:47 +02:00
|
|
|
if (count($parts) < 2) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ($parts[0] !== $paramName) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
return $parts[1];
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2014-08-02 20:51:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get all command line parameters
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public static function getAllParameters() {
|
|
|
|
global $argv;
|
|
|
|
return (array)$argv;
|
|
|
|
}
|
2014-05-01 20:15:47 +02:00
|
|
|
}
|