2017-11-03 00:09:34 +00:00
|
|
|
const { BaseCommand } = require('./base-command.js');
|
|
|
|
const { app } = require('./app.js');
|
|
|
|
const { _ } = require('lib/locale.js');
|
|
|
|
const { BaseModel } = require('lib/base-model.js');
|
|
|
|
const { Folder } = require('lib/models/folder.js');
|
2017-07-10 20:03:46 +00:00
|
|
|
|
|
|
|
class Command extends BaseCommand {
|
|
|
|
|
|
|
|
usage() {
|
2017-07-28 18:13:07 +00:00
|
|
|
return 'use <notebook>';
|
2017-07-10 20:03:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
description() {
|
2017-07-18 18:21:03 +00:00
|
|
|
return _('Switches to [notebook] - all further operations will happen within this notebook.');
|
2017-07-10 20:03:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
autocomplete() {
|
|
|
|
return { data: autocompleteFolders };
|
|
|
|
}
|
|
|
|
|
2017-10-24 22:37:36 +01:00
|
|
|
enabled() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-07-10 20:03:46 +00:00
|
|
|
async action(args) {
|
2017-07-11 18:17:23 +00:00
|
|
|
let folder = await app().loadItem(BaseModel.TYPE_FOLDER, args['notebook']);
|
2017-07-18 18:21:03 +00:00
|
|
|
if (!folder) throw new Error(_('Cannot find "%s".', args['notebook']));
|
2017-07-10 20:03:46 +00:00
|
|
|
app().switchCurrentFolder(folder);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Command;
|