示例#1
0
} elseif (file_exists($file) && is_readable($file)) {
    $input = file_get_contents($file);
}
$cli = new League\CLImate\CLImate();
$cli->out("");
if (file_exists(EDGERC)) {
    $cli->bold()->info("Updating Existing .edgerc File");
    $file = parse_ini_file(EDGERC, true, INI_SCANNER_RAW);
    if (isset($file[SECTION])) {
        $response = $cli->bold()->cyan()->input("Update existing section? (" . SECTION . ") [Y/n]")->prompt();
        if (strtolower($response) != 'y' && !empty($response)) {
            $cli->error("This script will now exit.");
            exit(-1);
        }
    } else {
        $cli->lightBlue("Adding new section: " . SECTION);
    }
} else {
    $cli->info("Creating new .edgerc file");
    $cli->lightBlue("Adding new section: " . SECTION);
}
foreach (parse($input) as $key => $value) {
    $file[SECTION][$key] = $value;
}
$out = '';
foreach ($file as $section => $config) {
    $out .= "[{$section}]\n";
    foreach ($config as $key => $value) {
        $out .= "{$key} = {$value}\n";
    }
    $out .= "\n";