一些检查失败了
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
52 行
1.3 KiB
TypeScript
52 行
1.3 KiB
TypeScript
import BaseCommand from './base-command';
|
|
import { _ } from '@joplin/lib/locale';
|
|
import BaseModel from '@joplin/lib/BaseModel';
|
|
import Folder from '@joplin/lib/models/Folder';
|
|
import uuid from '@joplin/lib/uuid';
|
|
|
|
class Command extends BaseCommand {
|
|
public override usage() {
|
|
return 'search <pattern> [notebook]';
|
|
}
|
|
|
|
public override description() {
|
|
return _('Searches for the given <pattern> in all the notes.');
|
|
}
|
|
|
|
public override compatibleUis() {
|
|
return ['gui'];
|
|
}
|
|
|
|
// eslint-disable-next-line id-denylist -- `notebook` is the CLI argument name declared in usage() and accessed via bracket notation; the identifier appears here only as a type property key
|
|
public override async action(args: { pattern: string; notebook?: string }) {
|
|
const pattern = args['pattern'];
|
|
const folderTitle = args['notebook'];
|
|
|
|
let folder = null;
|
|
if (folderTitle) {
|
|
folder = await Folder.loadByTitle(folderTitle);
|
|
if (!folder) throw new Error(_('Cannot find "%s".', folderTitle));
|
|
}
|
|
|
|
const searchId = uuid.create();
|
|
|
|
this.dispatch({
|
|
type: 'SEARCH_ADD',
|
|
search: {
|
|
id: searchId,
|
|
title: pattern,
|
|
query_pattern: pattern,
|
|
query_folder_id: folder ? folder.id : '',
|
|
type_: BaseModel.TYPE_SEARCH,
|
|
},
|
|
});
|
|
|
|
this.dispatch({
|
|
type: 'SEARCH_SELECT',
|
|
id: searchId,
|
|
});
|
|
}
|
|
}
|
|
|
|
module.exports = Command;
|