-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsearch.ts
31 lines (26 loc) · 1.01 KB
/
search.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { Command, flags } from "@oclif/command";
import { NotesResponse } from "../types";
import { bearExec } from "../utils/bear-exec";
import { logNotes } from "../utils/log";
import cmdFlags from "../utils/flags";
import { argsWithPipe } from "../utils/read-pipe";
export default class Search extends Command {
static description = [
"Fetch search results from Bear for all notes or for a specific tag.",
"Returns list of unique note identifiers and note titles."
].join("\n");
static flags = {
help: cmdFlags.help,
"show-window": cmdFlags["show-window"],
tag: flags.string({ char: "t", description: "tag to search into" }),
token: cmdFlags.token
};
static args = [{ name: "term", description: "string to search" }];
async run() {
const { args: cmdArgs, flags } = this.parse(Search);
const args = await argsWithPipe(Search.args, cmdArgs);
const params = { ...flags, ...args };
const response = await bearExec<NotesResponse>("search", params);
logNotes(response);
}
}