2017-11-03 02:09:34 +02:00
|
|
|
const { BaseCommand } = require('./base-command.js');
|
|
|
|
const { app } = require('./app.js');
|
2020-11-07 17:59:37 +02:00
|
|
|
const Setting = require('@joplin/lib/models/Setting').default;
|
|
|
|
const { _ } = require('@joplin/lib/locale');
|
|
|
|
const { ReportService } = require('@joplin/lib/services/report.js');
|
2017-07-13 20:09:47 +02:00
|
|
|
|
|
|
|
class Command extends BaseCommand {
|
|
|
|
usage() {
|
|
|
|
return 'status';
|
|
|
|
}
|
|
|
|
|
|
|
|
description() {
|
2017-07-18 20:21:03 +02:00
|
|
|
return _('Displays summary about the notes and notebooks.');
|
2017-07-13 20:09:47 +02:00
|
|
|
}
|
|
|
|
|
2019-09-13 00:16:42 +02:00
|
|
|
async action() {
|
2020-03-14 01:46:14 +02:00
|
|
|
const service = new ReportService();
|
|
|
|
const report = await service.status(Setting.value('sync.target'));
|
2017-07-13 20:09:47 +02:00
|
|
|
|
|
|
|
for (let i = 0; i < report.length; i++) {
|
2020-03-14 01:46:14 +02:00
|
|
|
const section = report[i];
|
2017-07-13 20:09:47 +02:00
|
|
|
|
2017-10-07 18:30:27 +02:00
|
|
|
if (i > 0) this.stdout('');
|
2017-07-13 20:09:47 +02:00
|
|
|
|
2019-09-19 23:51:18 +02:00
|
|
|
this.stdout(`# ${section.title}`);
|
2017-10-07 18:30:27 +02:00
|
|
|
this.stdout('');
|
2017-07-13 20:09:47 +02:00
|
|
|
|
2020-04-08 19:02:31 +02:00
|
|
|
let canRetryType = '';
|
|
|
|
|
2020-03-14 01:46:14 +02:00
|
|
|
for (const n in section.body) {
|
2017-07-13 20:09:47 +02:00
|
|
|
if (!section.body.hasOwnProperty(n)) continue;
|
2020-04-08 19:02:31 +02:00
|
|
|
const item = section.body[n];
|
|
|
|
|
|
|
|
if (typeof item === 'object') {
|
|
|
|
canRetryType = item.canRetryType;
|
|
|
|
this.stdout(item.text);
|
|
|
|
} else {
|
|
|
|
this.stdout(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (canRetryType === 'e2ee') {
|
|
|
|
this.stdout('');
|
|
|
|
this.stdout(_('To retry decryption of these items. Run `e2ee decrypt --retry-failed-items`'));
|
2017-07-13 20:09:47 +02:00
|
|
|
}
|
|
|
|
}
|
2017-10-25 19:23:45 +02:00
|
|
|
|
2020-04-08 19:02:31 +02:00
|
|
|
app().gui().showConsole();
|
|
|
|
app().gui().maximizeConsole();
|
2017-07-13 20:09:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-30 09:35:42 +02:00
|
|
|
module.exports = Command;
|