1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-02-10 19:41:43 +02:00
joplin/CliClient/app/command-attach.js
Laurent Cozic 55c5ddedf4 Revert "Applied prettier to code base"
This reverts commit c4f19465a676f2e154084707ade6b1766e1aba25.
2018-03-09 20:59:12 +00:00

32 lines
774 B
JavaScript

const { BaseCommand } = require('./base-command.js');
const { app } = require('./app.js');
const { _ } = require('lib/locale.js');
const BaseModel = require('lib/BaseModel.js');
const { shim } = require('lib/shim.js');
const fs = require('fs-extra');
class Command extends BaseCommand {
usage() {
return 'attach <note> <file>';
}
description() {
return _('Attaches the given file to the note.');
}
async action(args) {
let title = args['note'];
let note = await app().loadItem(BaseModel.TYPE_NOTE, title, { parent: app().currentFolder() });
this.encryptionCheck(note);
if (!note) throw new Error(_('Cannot find "%s".', title));
const localFilePath = args['file'];
await shim.attachFileToNote(note, localFilePath);
}
}
module.exports = Command;