joplin/CliClient/app/command-status.js

39 lines
860 B
JavaScript
Raw Normal View History

2017-07-13 18:09:47 +00:00
import { BaseCommand } from './base-command.js';
2017-07-16 16:06:05 +00:00
import { Database } from 'lib/database.js';
import { Setting } from 'lib/models/setting.js';
2017-07-13 18:09:47 +00:00
import { _ } from 'lib/locale.js';
import { ReportService } from 'lib/services/report.js';
class Command extends BaseCommand {
usage() {
return 'status';
}
description() {
2017-07-18 18:21:03 +00:00
return _('Displays summary about the notes and notebooks.');
2017-07-13 18:09:47 +00:00
}
async action(args) {
let service = new ReportService();
2017-07-24 18:58:11 +00:00
let report = await service.status(Setting.value('sync.target'));
2017-07-13 18:09:47 +00:00
for (let i = 0; i < report.length; i++) {
let section = report[i];
2017-10-07 16:30:27 +00:00
if (i > 0) this.stdout('');
2017-07-13 18:09:47 +00:00
2017-10-07 16:30:27 +00:00
this.stdout('# ' + section.title);
this.stdout('');
2017-07-13 18:09:47 +00:00
for (let n in section.body) {
if (!section.body.hasOwnProperty(n)) continue;
let line = section.body[n];
2017-10-07 16:30:27 +00:00
this.stdout(line);
2017-07-13 18:09:47 +00:00
}
}
}
}
module.exports = Command;