一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
40 行
1.2 KiB
TypeScript
40 行
1.2 KiB
TypeScript
import BaseCommand from './base-command';
|
|
import app from './app';
|
|
import { _ } from '@joplin/lib/locale';
|
|
import { ModelType } from '@joplin/lib/BaseModel';
|
|
import Folder from '@joplin/lib/models/Folder';
|
|
|
|
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: { 'notebook': string }) {
|
|
const folder = await app().loadItem(ModelType.Folder, args['notebook']);
|
|
if (!folder) throw new Error(_('Cannot find "%s".', args['notebook']));
|
|
|
|
// Auto-expand parent folders in GUI if present
|
|
if (app().gui() && app().gui().widget && app().gui().widget('folderList')) {
|
|
const folderListWidget = app().gui().widget('folderList');
|
|
if (folderListWidget.expandToFolder) {
|
|
// Get all folders to pass to expandToFolder
|
|
const folders = await Folder.all();
|
|
folderListWidget.folders = folders; // Ensure widget has current folders
|
|
folderListWidget.expandToFolder(folder.id);
|
|
}
|
|
}
|
|
|
|
app().switchCurrentFolder(folder);
|
|
}
|
|
}
|
|
|
|
module.exports = Command;
|