forked from jackwener/OpenCLI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtop.js
More file actions
29 lines (29 loc) · 1.1 KB
/
top.js
File metadata and controls
29 lines (29 loc) · 1.1 KB
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
import { cli, Strategy } from '@jackwener/opencli/registry';
cli({
site: 'hackernews',
name: 'top',
description: 'Hacker News top stories',
domain: 'news.ycombinator.com',
strategy: Strategy.PUBLIC,
browser: false,
args: [
{ name: 'limit', type: 'int', default: 20, help: 'Number of stories' },
],
columns: ['rank', 'title', 'score', 'author', 'comments'],
pipeline: [
{ fetch: { url: 'https://hacker-news.firebaseio.com/v0/topstories.json' } },
{ limit: '${{ Math.min((args.limit ? args.limit : 20) + 10, 50) }}' },
{ map: { id: '${{ item }}' } },
{ fetch: { url: 'https://hacker-news.firebaseio.com/v0/item/${{ item.id }}.json' } },
{ filter: 'item.title && !item.deleted && !item.dead' },
{ map: {
rank: '${{ index + 1 }}',
title: '${{ item.title }}',
score: '${{ item.score }}',
author: '${{ item.by }}',
comments: '${{ item.descendants }}',
url: '${{ item.url }}',
} },
{ limit: '${{ args.limit }}' },
],
});