1#!/usr/bin/env php
2#
3# this file updates release relevant meta things:
4# - updating READMEs with current cli --help output
5# - updating READMEs with contributors [not present yet]
6# - updating about Mandelbulber popup with contributors [not present yet]
7#
8# requires php (apt-get install php5-cli) and the current mandelbulber
9# executable in pathToCurrentMandelbulberExec (set locale to english)
10#
11
12<?php
13require_once(dirname(__FILE__) . '/common.inc.php');
14
15printStart();
16
17$newsContent = file_get_contents(PROJECT_PATH . 'deploy/NEWS');
18
19// $contributorsContent = file_get_contents(PROJECT_PATH .'contributors.txt');
20
21$helpOutput = getHelpOutput();
22$cliOptionString = substr($helpOutput, strpos($helpOutput, 'Options:') + strlen('Options:'));
23
24$readmes['linux']['path'] = PROJECT_PATH . 'deploy/README';
25$readmes['osx']['path'] = PROJECT_PATH . 'deploy/README-osx.txt';
26$readmes['win']['path'] = PROJECT_PATH . 'deploy/README-win32.txt';
27
28printStartGroup('WRITING HELP OUTPUT TO README');
29foreach ($readmes as $type => $readme) {
30    $status = array();
31	$success = updateReadme($readme, $status, $cliOptionString);
32	printResultLine(basename($readme['path']), $success, $status);
33}
34printEndGroup();
35printFinish();
36exit;
37
38// contributors to README
39// TODO
40
41// contributors to about Mandelbulber popup
42// TODO
43
44function updateReadme($readme, &$status, $cliOptionString)
45{
46	$oldContent = file_get_contents($readme['path']);
47	$content = $oldContent;
48	$content = substr($content, 0, strpos($content, 'Options:') + strlen('Options:'));
49	$content .= $cliOptionString;
50
51	if ($content != $oldContent) {
52		if (!isDryRun()) {
53			file_put_contents($readme['path'], $content);
54		}
55		$status[] = successString('readme changed');
56	}
57	return true;
58}
59
60function getHelpOutput()
61{
62	$cmd = MANDELBULBER_EXEC_PATH . ' --help';
63	$out = shell_exec($cmd);
64	return $out;
65}
66
67?>
68