-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconsole.ts
27 lines (25 loc) · 1.09 KB
/
console.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
import commander from 'commander';
import { BookAPIFetcher } from './src/Book/Fetcher/BookAPIFetcher';
import { BookBuilder } from './src/Book/Builder/BookBuilder';
import { PacktPubClient } from './src/Service/PacktPub/PacktPubClient';
import { SlackBookSender } from './src/Sender/SlackBookSender';
import { SlackClient } from './src/Service/Slack/SlackClient';
import { BookToSlackMessageConverter } from './src/Service/Message/BookToSlackMessageConverter';
import dotenv from 'dotenv';
dotenv.config();
commander.version('1.0.0').description('Send free packtpub book to slack');
commander
.command('send')
.alias('s')
.description('send message to slack channel')
.action(async () => {
try {
const bookApifetcher = await new BookAPIFetcher(new PacktPubClient(), new BookBuilder()).fetch();
new SlackBookSender(new SlackClient(process.env.SLACK_WEBHOOKS), new BookToSlackMessageConverter()).send(
bookApifetcher,
);
} catch (error) {
console.log(`${error.message}`);
}
});
commander.parse(process.argv);