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