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 { _ } = require('@joplin/lib/locale');
|
2021-01-22 19:41:11 +02:00
|
|
|
const Note = require('@joplin/lib/models/Note').default;
|
2017-07-10 22:03:46 +02:00
|
|
|
|
|
|
|
class Command extends BaseCommand {
|
|
|
|
usage() {
|
2017-08-04 18:02:43 +02:00
|
|
|
return 'mknote <new-note>';
|
2017-07-10 22:03:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
description() {
|
2017-07-18 20:21:03 +02:00
|
|
|
return _('Creates a new note.');
|
2017-07-10 22:03:46 +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-note'],
|
2017-07-11 20:17:23 +02:00
|
|
|
parent_id: app().currentFolder().id,
|
2017-07-10 22:03:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
note = await Note.save(note);
|
|
|
|
Note.updateGeolocation(note.id);
|
2017-10-22 19:12:16 +02:00
|
|
|
|
|
|
|
app().switchCurrentFolder(app().currentFolder());
|
2017-07-10 22:03:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-30 09:35:42 +02:00
|
|
|
module.exports = Command;
|