/ clis / linux-do / category.js
category.js
 1  import { cli, Strategy } from '@jackwener/opencli/registry';
 2  import { buildLinuxDoCompatFooter, executeLinuxDoFeed } from './feed.js';
 3  cli({
 4      site: 'linux-do',
 5      name: 'category',
 6      description: 'linux.do 分类内话题',
 7      domain: 'linux.do',
 8      strategy: Strategy.COOKIE,
 9      browser: true,
10      columns: ['title', 'replies', 'created', 'likes', 'views', 'url'],
11      deprecated: 'opencli linux-do category is kept for backward compatibility.',
12      replacedBy: 'opencli linux-do feed --category <id-or-name>',
13      args: [
14          {
15              name: 'slug',
16              positional: true,
17              type: 'str',
18              required: true,
19              help: 'Category slug (legacy compatibility argument)',
20          },
21          {
22              name: 'id',
23              positional: true,
24              type: 'int',
25              required: true,
26              help: 'Category ID',
27          },
28          { name: 'limit', type: 'int', default: 20, help: 'Number of items (per_page)' },
29      ],
30      func: async (page, kwargs) => executeLinuxDoFeed(page, {
31          limit: kwargs.limit,
32          category: String(kwargs.id),
33          view: 'latest',
34      }),
35      footerExtra: (kwargs) => buildLinuxDoCompatFooter(`opencli linux-do feed --category ${kwargs.id ?? '<id>'}`),
36  });