1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-27 10:32:58 +02:00
joplin/packages/app-cli/app/command-use.ts
2024-01-22 17:16:26 +00:00

27 lines
706 B
TypeScript

import BaseCommand from './base-command';
import app from './app';
import { _ } from '@joplin/lib/locale';
import BaseModel from '@joplin/lib/BaseModel';
class Command extends BaseCommand {
public override usage() {
return 'use <notebook>';
}
public override description() {
return _('Switches to [notebook] - all further operations will happen within this notebook.');
}
public override compatibleUis() {
return ['cli'];
}
public override async action(args: any) {
const folder = await app().loadItem(BaseModel.TYPE_FOLDER, args['notebook']);
if (!folder) throw new Error(_('Cannot find "%s".', args['notebook']));
app().switchCurrentFolder(folder);
}
}
module.exports = Command;