mirror of
https://github.com/OPSnet/Gazelle.git
synced 2026-01-16 18:04:34 -05:00
37 lines
766 B
PHP
Executable File
37 lines
766 B
PHP
Executable File
#! /usr/bin/env php
|
|
<?php
|
|
|
|
/**
|
|
* A command-line tool to expose configuration values
|
|
* Switches:
|
|
* -j encode the output as JSON (useful for arrays)
|
|
*
|
|
* usage:
|
|
* getconf SQLPASS
|
|
* (prints the db password)
|
|
*
|
|
* getconf -j RANKING_WEIGHT
|
|
* try it :)
|
|
*/
|
|
|
|
require_once(__DIR__ . '/../lib/config.php');
|
|
|
|
array_shift($argv);
|
|
$multi = count($argv) > 1;
|
|
$json = false;
|
|
|
|
foreach ($argv as $arg) {
|
|
switch($arg) {
|
|
case '-j':
|
|
$json = !$json;
|
|
break;
|
|
default:
|
|
$value = get_defined_constants()[$arg];
|
|
if ($json) {
|
|
echo json_encode($multi ? [$arg => $value] : $value), "\n";
|
|
} else {
|
|
echo ($multi ? "$arg: $value" : $value), "\n";
|
|
}
|
|
}
|
|
}
|