refactor cli

This commit is contained in:
Michael Hohn
2025-03-15 18:09:29 -07:00
parent cd568db7b4
commit 012e597d4a

View File

@@ -157,6 +157,38 @@ export class CodeQLCliServer implements Disposable {
this.setupListeners();
}
async bqrsDecode(
bqrsPath: string,
resultSet: string,
{ pageSize, offset, entities = ["url", "string"] }: BqrsDecodeOptions = {},
): Promise<DecodedBqrsChunk> {
const args = [
`--entities=${entities.join(",")}`,
"--result-set",
resultSet,
...(pageSize ? ["--rows", pageSize.toString()] : []),
...(offset ? ["--start-at", offset.toString()] : []),
bqrsPath,
];
return this.runJsonCodeQlCliCommand<DecodedBqrsChunk>(
["bqrs", "decode"],
args,
"Reading bqrs data",
);
}
async bqrsInfo(bqrsPath: string, pageSize?: number): Promise<BqrsInfo> {
const args = pageSize
? ["--paginate-rows", pageSize.toString(), bqrsPath]
: [bqrsPath];
return this.runJsonCodeQlCliCommand<BqrsInfo>(
["bqrs", "info"],
args,
"Reading bqrs header",
);
}
private setupListeners() {
this.distributionProvider.onDidChangeDistribution?.(() =>
this.restartCliServer(),