1 | #! /usr/bin/env node
|
2 | 'use strict';
|
3 |
|
4 | var open = require('open');
|
5 | var getNextMeeting = require('./lib');
|
6 | var program = require('commander');
|
7 | var asciify = require('asciify');
|
8 | var chalk = require('chalk');
|
9 | var path = require('path');
|
10 | var pkg = require(path.join(__dirname, 'package.json'));
|
11 |
|
12 | program
|
13 | .version(pkg.version)
|
14 | .option('-d, --details', 'More details about the meetup')
|
15 | .option('-m, --map', 'Google Map to Meetup location')
|
16 | .option('-l, --link', 'Open the home page url')
|
17 | .option('-a, --address', 'Show the venue address')
|
18 | .option('-e, --easteregg', 'Tell you friends to \'jnn -e\' LoL!')
|
19 | .parse(process.argv);
|
20 |
|
21 | function main(nextMeeting) {
|
22 | asciify('JaxNode', { font: 'larry3d', color: 'green' }, function (err, res) {
|
23 | console.log(res);
|
24 |
|
25 | var mapurl = 'https://www.google.com/maps/place/' + nextMeeting.meeting.venue.name + '/@' + nextMeeting.meeting.venue.lat + ',' + nextMeeting.meeting.venue.lon + 'z18';
|
26 | var meetingText = 'The next JaxNode meeting will be on ' + nextMeeting.meeting.time + ' at ' + nextMeeting.meeting.venue.name;
|
27 |
|
28 | console.log(meetingText);
|
29 |
|
30 | if (program.details) {
|
31 | var cleanDescription = nextMeeting.meeting.description.replace(/( |<([^>]+)>)/ig, '');
|
32 | console.log(chalk.yellow.bold(nextMeeting.meeting.name + ': ') + chalk.yellow(cleanDescription));
|
33 | }
|
34 | if (program.map) {
|
35 | open(mapurl);
|
36 | }
|
37 | if (program.link) {
|
38 | open('https://www.jaxnode.com');
|
39 | }
|
40 | if (program.address) {
|
41 | console.log(nextMeeting.meeting.venue.name);
|
42 | console.log(nextMeeting.meeting.venue.address_1);
|
43 | console.log(nextMeeting.meeting.venue.city + ', ' + nextMeeting.meeting.venue.state);
|
44 | }
|
45 | if (program.easteregg) {
|
46 | open('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
|
47 | }
|
48 | });
|
49 | }
|
50 |
|
51 | getNextMeeting(main);
|