fix: search pagination output (#42) (thanks @pjtf93)
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
- `replies` and `thread` now support pagination (`--all`, `--max-pages`, `--cursor`, `--delay`) (#35) — thanks @crcatala.
|
||||
- Long-form article tweets now render rich Draft.js content blocks/entities (#36) — thanks @crcatala.
|
||||
- `news`/`trending` command for Explore tabs with AI-curated headlines (#39) — thanks @aavetis.
|
||||
- `search` now supports pagination (`--all`, `--max-pages`, `--cursor`) (#42) — thanks @pjtf93.
|
||||
|
||||
### Changed
|
||||
- Library typing: `SearchResult` is now a discriminated union (so `error` only exists when `success: false`).
|
||||
|
||||
+14
-2
@@ -14,7 +14,18 @@ export function registerSearchCommands(program: Command, ctx: CliContext): void
|
||||
.option('--cursor <string>', 'Resume pagination from a cursor')
|
||||
.option('--json', 'Output as JSON')
|
||||
.option('--json-full', 'Output as JSON with full raw API response in _raw field')
|
||||
.action(async (query: string, cmdOpts: { count?: string; all?: boolean; maxPages?: string; cursor?: string; json?: boolean; jsonFull?: boolean }) => {
|
||||
.action(
|
||||
async (
|
||||
query: string,
|
||||
cmdOpts: {
|
||||
count?: string;
|
||||
all?: boolean;
|
||||
maxPages?: string;
|
||||
cursor?: string;
|
||||
json?: boolean;
|
||||
jsonFull?: boolean;
|
||||
},
|
||||
) => {
|
||||
const opts = program.opts();
|
||||
const timeoutMs = ctx.resolveTimeoutFromOptions(opts);
|
||||
const quoteDepth = ctx.resolveQuoteDepthFromOptions(opts);
|
||||
@@ -65,7 +76,8 @@ export function registerSearchCommands(program: Command, ctx: CliContext): void
|
||||
console.error(`${ctx.p('err')}Search failed: ${result.error}`);
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
program
|
||||
.command('mentions')
|
||||
|
||||
@@ -68,7 +68,11 @@ export function withSearch<TBase extends AbstractConstructor<TwitterClientBase>>
|
||||
return this.searchPaged(query, Number.POSITIVE_INFINITY, options);
|
||||
}
|
||||
|
||||
private async searchPaged(query: string, limit: number, options: SearchPaginationOptions = {}): Promise<SearchResult> {
|
||||
private async searchPaged(
|
||||
query: string,
|
||||
limit: number,
|
||||
options: SearchPaginationOptions = {},
|
||||
): Promise<SearchResult> {
|
||||
const features = buildSearchFeatures();
|
||||
const pageSize = 20;
|
||||
const seen = new Set<string>();
|
||||
|
||||
Reference in New Issue
Block a user