/ clis / v2ex / topic.js
topic.js
 1  import { cli, Strategy } from '@jackwener/opencli/registry';
 2  cli({
 3      site: 'v2ex',
 4      name: 'topic',
 5      description: 'V2EX 主题详情和回复',
 6      domain: 'www.v2ex.com',
 7      strategy: Strategy.PUBLIC,
 8      browser: false,
 9      args: [
10          { name: 'id', required: true, positional: true, help: 'Topic ID' },
11      ],
12      columns: ['id', 'title', 'content', 'member', 'created', 'node', 'replies', 'url'],
13      pipeline: [
14          { fetch: {
15                  url: 'https://www.v2ex.com/api/topics/show.json',
16                  params: { id: '${{ args.id }}' },
17              } },
18          { map: {
19                  id: '${{ item.id }}',
20                  title: '${{ item.title }}',
21                  content: '${{ item.content }}',
22                  member: '${{ item.member.username }}',
23                  created: '${{ item.created }}',
24                  node: '${{ item.node.title }}',
25                  replies: '${{ item.replies }}',
26                  url: '${{ item.url }}',
27              } },
28          { limit: 1 },
29      ],
30  });