This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const gEvent = require('vorpal')(); | |
const {google} = require('googleapis'); | |
const opn = require('opn'); | |
const CLIENT_ID = 'GOOGLE_CLIENT_ID'; | |
const CLIENT_SECRET = 'GOOGLE_CLIENT_SECRET'; | |
const REDIRECT_URL = 'urn:ietf:wg:oauth:2.0:oob'; | |
const oauth2Client = new google.auth.OAuth2( | |
CLIENT_ID, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const path = require('path'); | |
const readConfig = () => { | |
const rawConfig = fs.readFileSync(path.join(__dirname, 'config.json'), 'utf8'); | |
return JSON.parse(rawConfig); | |
}; | |
module.exports.readConfig = readConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const gEvent = require('vorpal')(); | |
const {google} = require('googleapis'); | |
const opn = require('opn'); | |
const utils = require('./utils'); | |
const CLIENT_ID = 'GOOGLE_CLIENT_ID'; | |
const CLIENT_SECRET = 'GOOGLE_CLIENT_SECRET'; | |
const REDIRECT_URL = 'urn:ietf:wg:oauth:2.0:oob'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const vorpal = require('vorpal')(); | |
vorpal | |
.command('say [words...]') | |
.description('Echo what you type') | |
.action(function (args, callback) { | |
this.log(args.words.join(' ')); | |
callback(); | |
}); | |
vorpal | |
.delimiter('echo $') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gEvent | |
.command('list [date...]') | |
.description('List google event') | |
.action(async function(args, callback) { | |
const calendar = google.calendar({ | |
version: 'v3', | |
auth: oauth2Client | |
}); | |
const res = await calendar.events.list({ | |
calendarId: 'primary', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gEvent | |
.command('list') | |
.option('-f, --from [date]', 'Get events from the date[chrono based date parsing]') | |
.option('-t, --to [date]', 'Get events until the date [chrono based date parsing]') | |
.option('-r, --results <events>', 'Number of events to show') | |
.description('List google event') | |
.action(async function(args, callback) { | |
const calender = google.calendar({ | |
version: 'v3', | |
auth: oauth2Client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gEvent | |
.command('create [summary...]') | |
.option('-s, --start [date]', 'Set start date[chrono based date parsing]') | |
.option('-e, --end [date]', 'Set end date[chrono based date parsing]') | |
.option('-l, --location [eventLocation]', 'Set location of the event') | |
.option('--notify', 'Notify me about the event') | |
.validate(function (args) { | |
if (!args.options.start) { | |
return 'start date is missing'; | |
} else if (!args.options.end) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gEvent | |
.command('list') | |
.option('-f, --from [date]', 'Get events from the date[chrono based date parsing]') | |
.option('-t, --to [date]', 'Get events until the date[chrono based date parsing]') | |
.option('-r, --results <events>', 'Number of events to show') | |
.description('List google event') | |
.action(async function(args, callback) { | |
const spinner = new Spinner('Syncing data.. %s'); | |
spinner.setSpinnerString('▖▘▝▗'); | |
spinner.start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {google} = require('googleapis'); | |
const calendar = google.calendar({ | |
version: 'v3', | |
auth: oauth2Client | |
}); | |
const res = await calendar.events.list({ | |
calendarId: 'primary', | |
maxResults: 10 | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Spinner = require('cli-spinner').Spinner; | |
// Create a spinner | |
const spinner = new Spinner('Syncing data.. %s'); | |
// Set a string, that shows loding and replaced with %s in above declaration | |
spinner.setSpinnerString('▖▘▝▗'); | |
// Now you can start spinner when ever you want | |
// For our case before http request |
OlderNewer