Add dry-run flag & makefile target

dev
gravel 1 year ago
parent 2669e975f1
commit 35fe0faaf0
Signed by: gravel
GPG Key ID: C0538F3C906B308F

@ -16,14 +16,14 @@
include_once "$PROJECT_ROOT/php/utils/logging.php";
// Read the -v|--verbose option increasing logging verbosity to debug.
$options = getopt("v", ["verbose", "fast", "no-color"]);
$options = getopt("vn", ["verbose", "fast", "no-color", "dry-run"]);
if (isset($options["v"]) or isset($options["verbose"])) {
$LOGGING_VERBOSITY = LoggingVerbosity::Debug;
}
if (isset($options["fast"])) {
$FAST_FETCH_MODE = true;
}
$FAST_FETCH_MODE = (isset($options["fast"]));
$DO_DRY_RUN = (isset($options["n"]) || isset($options["dry-run"]));
if (isset($options["no-color"])) {
LoggingVerbosity::$showColor = false;

@ -18,6 +18,10 @@ all: fetch html
fetch:
/bin/php php/fetch-servers.php $(FLAGS)
# Fetch room listing without writing to disk.
fetch-dry:
/bin/php php/fetch-servers.php $(FLAGS) --dry-run
# Generate HTML from data.
html:
/bin/php php/generate-html.php $(FLAGS)

@ -22,7 +22,7 @@
* 6. De-dupe servers based on pubkey
*/
function main() {
global $CACHE_ROOT, $ROOMS_FILE, $KNOWN_SERVERS, $KNOWN_PUBKEYS;
global $CACHE_ROOT, $ROOMS_FILE, $KNOWN_SERVERS, $KNOWN_PUBKEYS, $DO_DRY_RUN;
// Create default directories..
file_exists($CACHE_ROOT) or mkdir($CACHE_ROOT, 0700);
@ -61,7 +61,7 @@
);
// Output fetching results to file.
file_put_contents($ROOMS_FILE, json_encode($servers));
if (!$DO_DRY_RUN) file_put_contents($ROOMS_FILE, json_encode($servers));
}
/**

Loading…
Cancel
Save