-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.ts
40 lines (39 loc) · 1.19 KB
/
list.ts
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
30
31
32
33
34
35
36
37
38
39
40
import chalk from 'chalk';
import { cli } from 'cli-ux';
import wrapAnsi = require('wrap-ansi');
import { Logger } from '../../service/logger';
import { PubSubService } from '../../index';
import { SubscriberTuple } from '../../subscriber';
export default {
command: 'list',
desc: 'Lists all subscriptions',
handler: async (): Promise<void> => {
Logger.Instance.info(
chalk.white.bgBlue.bold('\n Google Pub/Sub Subscriptions \n'),
);
if (PubSubService.getInstance().getSubscribers().length == 0) {
Logger.Instance.warn(chalk.white.bold('\n No subscriptions found'));
} else {
cli.table(
PubSubService.getInstance().getSubscribers(),
{
'Topic Name': {
get: (row: SubscriberTuple): string => row[1].topicName,
},
'Subscription Name': {
get: (row: SubscriberTuple): string => row[1].subscriptionName,
},
Description: {
get: (row: SubscriberTuple): string =>
wrapAnsi(row[1].description || '', 100),
},
},
{
printLine: Logger.Instance.info,
},
);
Logger.Instance.info('\n');
process.exit(0);
}
},
};