2014-05-01 20:15:47 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace ManiaControl;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Command Line Helper Class
|
2014-05-02 17:40:47 +02:00
|
|
|
*
|
|
|
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
|
|
|
* @copyright 2014 ManiaControl Team
|
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
2014-05-01 20:15:47 +02:00
|
|
|
*/
|
|
|
|
class CommandLineHelper {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Command Line Parameter with the given Name
|
2014-05-02 17:40:47 +02:00
|
|
|
*
|
2014-05-01 20:15:47 +02:00
|
|
|
* @param string $paramName
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public static function getParameter($paramName) {
|
|
|
|
global $argv;
|
2014-05-02 17:40:47 +02:00
|
|
|
$paramName = (string)$paramName;
|
2014-05-01 20:15:47 +02:00
|
|
|
foreach ($argv as $arg) {
|
|
|
|
$parts = explode('=', $arg, 2);
|
|
|
|
if (count($parts) < 2) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ($parts[0] !== $paramName) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
return $parts[1];
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|