Add JSON output for backups

Conflicts:
	lib/useractivitystream.php
This commit is contained in:
Evan Prodromou
2013-05-24 13:50:24 -04:00
parent ea8151688e
commit 1c1bcd7cc6
2 changed files with 87 additions and 29 deletions

View File

@@ -19,8 +19,8 @@
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
$shortoptions = 'i:n:f:';
$longoptions = array('id=', 'nickname=', 'file=');
$shortoptions = 'i:n:f:j';
$longoptions = array('id=', 'nickname=', 'file=', 'json');
$helptext = <<<END_OF_EXPORTACTIVITYSTREAM_HELP
exportactivitystream.php [options]
@@ -28,7 +28,7 @@ Export a StatusNet user history to a file
-i --id ID of user to export
-n --nickname nickname of the user to export
-f --file file to export to (default STDOUT)
-j --json Output JSON (default Atom)
END_OF_EXPORTACTIVITYSTREAM_HELP;
@@ -37,7 +37,11 @@ require_once INSTALLDIR.'/scripts/commandline.inc';
try {
$user = getUser();
$actstr = new UserActivityStream($user, true, UserActivityStream::OUTPUT_RAW);
print $actstr->getString();
if (have_option('j', 'json')) {
$actstr->writeJSON(STDOUT);
} else {
print $actstr->getString();
}
} catch (Exception $e) {
print $e->getMessage()."\n";
exit(1);