diff --git a/src/cli/index.js b/src/cli/index.js index e92d4b6fa1..a59ffd04c7 100644 --- a/src/cli/index.js +++ b/src/cli/index.js @@ -210,10 +210,10 @@ program }) .description('List all installed plugins'); program - .command('events') - .description('Outputs the last ten (10) administrative events recorded by NodeBB') - .action(function () { - require('./manage').listEvents(); + .command('events [count]') + .description('Outputs the most recent administrative events recorded by NodeBB') + .action(function (count) { + require('./manage').listEvents(count); }); program .command('info') diff --git a/src/cli/manage.js b/src/cli/manage.js index 9d360494ec..d029a693fe 100644 --- a/src/cli/manage.js +++ b/src/cli/manage.js @@ -97,10 +97,10 @@ function listPlugins() { }); } -function listEvents() { +function listEvents(count) { async.series([ db.init, - events.output, + async.apply(events.output, count), ]); } diff --git a/src/events.js b/src/events.js index 6da4abda5b..0617d79029 100644 --- a/src/events.js +++ b/src/events.js @@ -193,9 +193,14 @@ events.deleteAll = function (callback) { }, { alwaysStartAt: 0 }, callback); }; -events.output = function () { - console.log('\nDisplaying last ten administrative events...'.bold); - events.getEvents('', 0, 9, function (err, events) { +events.output = function (numEvents) { + numEvents = parseInt(numEvents, 10); + if (isNaN(numEvents)) { + numEvents = 10; + } + + console.log(('\nDisplaying last ' + numEvents + ' administrative events...').bold); + events.getEvents('', 0, numEvents - 1, function (err, events) { if (err) { winston.error('Error fetching events', err); throw err;