Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Run an immediate web search.

- Pick the effort with `--depth`: `fast`, `standard` (default), or `deep`.
- Choose the output with `--output`: `sourced-answer`, `search-results`, or `structured`.
- Use `--include-images` and `--max-results` with any output type.
- Add `--include-inline-citations` to sourced answers or `--include-sources` to structured output.

```bash
Expand Down
5 changes: 5 additions & 0 deletions src/__tests__/search.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ describe('search command integration', () => {
'hello world',
'--depth',
'deep',
'--include-images',
'--include-inline-citations',
'--max-results',
'8',
]);

expect(fakeClient.search).toHaveBeenCalledWith({
depth: 'deep',
includeImages: true,
includeInlineCitations: true,
maxResults: 8,
outputType: 'sourcedAnswer',
query: 'hello world',
});
Expand Down
9 changes: 4 additions & 5 deletions src/__tests__/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ describe('buildSearchParams', () => {
).toThrow('--schema/--schema-file cannot be used with --output search-results');
});

it('warns and omits search-result-only options for sourced answers', () => {
it('maps general image and limit options for sourced answers', () => {
const { params, warnings } = buildSearchParams('q', {
depth: 'standard',
includeImages: true,
Expand All @@ -158,13 +158,12 @@ describe('buildSearchParams', () => {

expect(params).toEqual({
depth: 'standard',
includeImages: true,
maxResults: 5,
outputType: 'sourcedAnswer',
query: 'q',
});
expect(warnings).toEqual([
'Warning: --include-images ignored (only used with --output search-results)',
'Warning: --max-results ignored (only used with --output search-results)',
]);
expect(warnings).toEqual([]);
});

it('warns and omits output-specific citation and source options', () => {
Expand Down
15 changes: 3 additions & 12 deletions src/commands/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,6 @@ function addIgnoredOptionWarnings(
): void {
addSchemaIgnoredWarning(opts.outputType, hasSchemaOption, warnings);

if (opts.outputType !== 'searchResults' && opts.includeImages) {
warnings.push('Warning: --include-images ignored (only used with --output search-results)');
}

if (opts.outputType !== 'searchResults' && opts.maxResults !== undefined) {
warnings.push('Warning: --max-results ignored (only used with --output search-results)');
}

if (opts.outputType !== 'sourcedAnswer' && opts.includeInlineCitations) {
warnings.push(
'Warning: --include-inline-citations ignored (only used with --output sourced-answer)',
Expand All @@ -164,9 +156,8 @@ function addIgnoredOptionWarnings(
function buildSearchExtraParams(opts: SearchCliOptions): Partial<SearchParams> {
return {
...buildCommonParams(opts),
...(opts.outputType === 'searchResults' && opts.includeImages && { includeImages: true }),
...(opts.outputType === 'searchResults' &&
opts.maxResults !== undefined && { maxResults: opts.maxResults }),
...(opts.includeImages && { includeImages: true }),
...(opts.maxResults !== undefined && { maxResults: opts.maxResults }),
...(opts.outputType === 'sourcedAnswer' &&
opts.includeInlineCitations && { includeInlineCitations: true }),
...(opts.outputType === 'structured' && opts.includeSources && { includeSources: true }),
Expand Down Expand Up @@ -249,7 +240,7 @@ export function registerSearchCommand(program: Command): void {
'Only include results published on or before this date',
parseDateOption('--to-date'),
)
.option('--include-images', 'Request images in search results')
.option('--include-images', 'Include images in search output')
.option('--include-inline-citations', 'Include inline citations in sourced answers')
.option('--include-sources', 'Include source records with structured output')
.option('--max-results <number>', 'Maximum number of search results', parsePositiveInt)
Expand Down