added command line helper
This commit is contained in:
parent
f6bcb8823d
commit
07aba111c4
35
application/core/CommandLineHelper.php
Normal file
35
application/core/CommandLineHelper.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl;
|
||||
|
||||
/**
|
||||
* Command Line Helper Class
|
||||
*
|
||||
* @author steeffeen & kremsy
|
||||
* @copyright ManiaControl Copyright © 2014 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class CommandLineHelper {
|
||||
|
||||
/**
|
||||
* Get the Command Line Parameter with the given Name
|
||||
*
|
||||
* @param string $paramName
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getParameter($paramName) {
|
||||
global $argv;
|
||||
$paramName = (string) $paramName;
|
||||
foreach ($argv as $arg) {
|
||||
$parts = explode('=', $arg, 2);
|
||||
if (count($parts) < 2) {
|
||||
continue;
|
||||
}
|
||||
if ($parts[0] !== $paramName) {
|
||||
continue;
|
||||
}
|
||||
return $parts[1];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user