9b395f5cc3
Build Chrome Extension / build (push) Waiting to run
Trigger Website Rebuild (Docs Updated) / dispatch (push) Waiting to run
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
29 lines
1002 B
JavaScript
29 lines
1002 B
JavaScript
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
cli({
|
|
site: 'dictionary',
|
|
name: 'examples',
|
|
access: 'read',
|
|
description: 'Read real-world example sentences utilizing the word',
|
|
domain: 'api.dictionaryapi.dev',
|
|
strategy: Strategy.PUBLIC,
|
|
browser: false,
|
|
args: [
|
|
{
|
|
name: 'word',
|
|
type: 'string',
|
|
required: true,
|
|
positional: true,
|
|
help: 'Word to get example sentences for',
|
|
},
|
|
],
|
|
columns: ['word', 'example'],
|
|
pipeline: [
|
|
{ fetch: { url: 'https://api.dictionaryapi.dev/api/v2/entries/en/${{ args.word | urlencode }}' } },
|
|
{ map: {
|
|
word: '${{ item.word }}',
|
|
example: `\${{ (() => { if (item.meanings) { for (const m of item.meanings) { if (m.definitions) { for (const d of m.definitions) { if (d.example) return d.example; } } } } return 'No example found in API.'; })() }}`,
|
|
} },
|
|
{ limit: 1 },
|
|
],
|
|
});
|