1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-15 09:04:04 +02:00
joplin/CliClient/app/command-use.js
2017-07-10 20:03:46 +00:00

35 lines
762 B
JavaScript

import { BaseCommand } from './base-command.js';
import { app } from './app.js';
import { _ } from 'lib/locale.js';
import { Folder } from 'lib/models/folder.js';
import { autocompleteFolders } from './autocomplete.js';
class Command extends BaseCommand {
usage() {
return 'use <notebook>';
}
description() {
return 'Switches to [notebook] - all further operations will happen within this notebook.';
}
aliases() {
return ['cd'];
}
autocomplete() {
return { data: autocompleteFolders };
}
async action(args) {
let title = args['notebook'];
let folder = await Folder.loadByField('title', title);
if (!folder) throw new Error(_('Invalid folder title: %s', title));
app().switchCurrentFolder(folder);
}
}
module.exports = Command;