2017-11-03 02:09:34 +02:00
|
|
|
const { BaseCommand } = require('./base-command.js');
|
|
|
|
const { app } = require('./app.js');
|
|
|
|
const { _ } = require('lib/locale.js');
|
2017-12-14 20:12:14 +02:00
|
|
|
const Note = require('lib/models/Note.js');
|
2017-07-31 20:57:31 +02:00
|
|
|
|
|
|
|
class Command extends BaseCommand {
|
|
|
|
|
|
|
|
usage() {
|
2017-08-04 18:02:43 +02:00
|
|
|
return 'mktodo <new-todo>';
|
2017-07-31 20:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
description() {
|
2017-10-30 02:37:34 +02:00
|
|
|
return _('Creates a new to-do.');
|
2017-07-31 20:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async action(args) {
|
|
|
|
if (!app().currentFolder()) throw new Error(_('Notes can only be created within a notebook.'));
|
|
|
|
|
|
|
|
let note = {
|
2017-08-04 18:02:43 +02:00
|
|
|
title: args['new-todo'],
|
2017-07-31 20:57:31 +02:00
|
|
|
parent_id: app().currentFolder().id,
|
|
|
|
is_todo: 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
note = await Note.save(note);
|
|
|
|
Note.updateGeolocation(note.id);
|
2017-10-22 19:12:16 +02:00
|
|
|
|
|
|
|
app().switchCurrentFolder(app().currentFolder());
|
2017-07-31 20:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Command;
|