-
Notifications
You must be signed in to change notification settings - Fork 75
/
view.ts
40 lines (35 loc) · 1.17 KB
/
view.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 EasCommand from '../../commandUtils/EasCommand';
import { WebhookQuery } from '../../graphql/queries/WebhookQuery';
import Log from '../../log';
import { ora } from '../../ora';
import { formatWebhook } from '../../webhooks/formatWebhook';
export default class WebhookView extends EasCommand {
static override description = 'view a webhook';
static override args = [
{
name: 'ID',
required: true,
description: 'ID of the webhook to view',
},
];
static override contextDefinition = {
...this.ContextOptions.LoggedIn,
};
async runAsync(): Promise<void> {
const {
args: { ID: webhookId },
} = await this.parse(WebhookView);
const {
loggedIn: { graphqlClient },
} = await this.getContextAsync(WebhookView, { nonInteractive: true });
const spinner = ora(`Fetching the webhook details for ID ${webhookId}`).start();
try {
const webhook = await WebhookQuery.byIdAsync(graphqlClient, webhookId);
spinner.succeed(`Found the webhook details`);
Log.log(`\n${formatWebhook(webhook)}`);
} catch (err) {
spinner.fail(`Couldn't find the webhook with ID ${webhookId}`);
throw err;
}
}
}