gcal-cli Google Calendar command line tool for Nod开源项目

我要开发同款
匿名用户2021年11月17日
31阅读
开发技术JavaScript
所属分类应用工具、终端/远程登录
授权协议Readme

作品详情

gcal

GoogleCalendarcommandlinetoolforNode.js

Programmaticeventlisting,insertorbulkinsertmadeeasy:

$gcalinsert'Partytomorrowfrom3pmto5pm'Party:2017-09-08T15:00:00+09:00~2017-09-08T17:00:00+09:00https://www.google.com/calendar/event?eid=amNpMWE5cjg2bG80n2s0Nmg1ZWlqcW01OXMgdG9rYWdlcm9oQG0$echo\'[{"calendarId":"primary","resource":{"summary":"Party","start":{"dateTime":"2017-09-08T20:00"},"end":{"dateTime":"2017-09-08T22:00"}}},{"calendarId":"primary","resource":{"summary":"Partyagain","start":{"dateTime":"2017-09-08T22:00"},"end":{"dateTime":"2017-09-08T23:30"}}}]'\>events.json$gcalbulk-eevents.jsonEventinsertedid:gif4hl86kgt7bmgq2ojvteqe2osummary:PartyhtmlLink:https://www.google.com/calendar/event?eid=Z2lmNGhsODZrZ3Q3Ym1ncTJvanZ0ZXFlMm8gdG9rYWdlcm9oQG0Eventinsertedid:blrrb8kbrih3pq9mn10slii8acsummary:PartyagainhtmlLink:https://www.google.com/calendar/event?eid=YmxycmI4a2JyaWgzcHE5bW4xMHNsaWk4YWMgdG9rYWdlcm9oQG0$gcallistUpcomingevents(2017-09-07T00:00:00+09:00~2017-09-07T23:59:59+09:00)2017-09-0720:00-MyfavoriteTVshow2017-09-0722:30-Preparetomorrow'smeetingstuffInstallation

Installitasaglobalmodule:

npminstall-ggcalAuthentication

AuthorizationandauthenticationisdonewithOAuth2.0.

Ok,thiswilltakeonly2minutes:

1)Getyourprojectcredentials

Youwillneedafilewithyourcredentials:clientID,clientsecretandredirectURI.ThiscanbeobtainedintheDeveloperConsole:

GotoyourprojectClickinCredentialsClickCreatecredentials→OAuthclientID(ApplicationtypemustbeOther)DownloadtheJSONfile2)GenerateconsentpageURL

OncewegotthecredentialswemustgenerateaconsentpageURL.

$gcalgenerateUrl

(Bydefaultthecredentialswillbesearchedinyourhomedirectoryunderthenameclient_secret.json).

Thepagewillpromptyoutoauthorizeaccess,followtheinstructions.

3)Getthetoken!

Withthecodewegotthroughtheauthorizationpage,wecanobtainatokenandstoreitinourmachine.

$gcalstoreToken<code>

(Bydefaultthetokenisstoredinyourhomefolderunderthenamecalendar_api_token.json).

NOTE:Thetokenwillexpiryafteronehour,butarefresh_tokenisincludedaswell,allowingtheapptorefreshautomaticallythetokeneachtimeit'sused.

Withthiswearegoodtogo.Thestoredtokenandcredentialsfileswillberequiredfromnowontousethistool.

UsageList

Listtodayevents:

$gcallist

Listeventsusingnaturallanguage(poweredbySherlock):

$gcallisttomorrow$gcallist'from03/23/2017to03/27/2017'$gcallist'fromMarch23thto27th'

OrwithspecificISOdates:

$gcallist-f2017-03-23-t2017-03-27Insert

Inserteventsusingnaturallanguage:

$gcalinsert'Partytomorrowfrom3pmto5pm'

Inserteventsspecifyingtheparameters:

$gcalinsert-s'Party'-d2017-03-23-t15:00-D2hBulkInsert

Bulkinsertpassinga.jsor.jsonfile:

events.json

[{"calendarId":"primary","resource":{"summary":"HavingcoffeewithOkuyasu","location":"MorioCity","description":"I'mnotveryimaginativenowsosomedescriptiongoeshere","start":{"dateTime":"2017-09-08T09:00:00"},"end":{"dateTime":"2017-09-08T10:00:00"}}},{"calendarId":"primary","resource":{"summary":"DefeatDio","location":"179OroubaSt,Cairo","description":"DioisabadboysoIneedtokickhisassasap","start":{"date":"1987-06-01"},"end":{"date":"1987-06-12"}}}]$gcalbulk-e./events.json

Usinga.jsfilecanbeusefulforrelativedatesandmore:

events.js

consttoday=newDate();today.setHours('17','00','00');consttomorrow=newDate(today.getTime()+1000*60*60*24);module.exports=[{"calendarId":"primary","resource":{"summary":`Release`,"start":{"dateTime":today.toISOString()},"end":{"dateTime":today.toISOString()}}},{"calendarId":"primary","resource":{"summary":"Release","start":{"dateTime":tomorrow.toISOString()},"end":{"dateTime":tomorrow.toISOString()}}}];$gcalbulk-e./events.js

Theavailablepropertiesarelistedhere.

Overwritingdefaultconfig

Usingtheoption-C<file>thedefaultconfigcanbeoverwritten.Thisfilemustbe.jsor.json.Configurableoptionsarelocatedin./conf.js.

Example:

/somepath/config.json

{"CRED_PATH":"/my/secret/path/credentials.json","TOKEN_PATH":"/my/secret/path/token.json"}$gcal-C/somepath/config.jsongenerateUrl

Doingthisyoucanstoreyourcredentialfileswhereveryouwant.

API

Usethehelpcommand.Moredetailswillbeaddedsoon.

$gcalhelp

Usage:gcal[-C<file>][cmd][--debug]OPTIONS-C,--config<file>--debugCommands:list[<term>|[-f<date|datetime>][-t<date|datetime>]][-i]Listevents.Bydefaultitshowstodayevents(executedwithoutarguments).OPTIONS-f,--from<date|datetime>-t,--to<date|datetime>-i,--show-idinsert<term>|-s<summary>-d<date>[-t<time>][-D<duration>]Insertevents.<term>isspecifiedinnaturallanguage,incaseit'snotspecified,-sand-daremandatory.OPTIONS-s,--summary<summary>-d,--date<date>-t,--time<time>-D,--duration<duration>bulk-e<file>Bulkinsertofevents.Filecanbe.jsonor.js.OPTIONS-e,--events<file>generateUrlGenerateconsentpageURL.Inordertoworkclient_secret.jsmustbeinyourhomefolder.storeToken<code>StoreTokeninyourhomefolder.helpShowthishelppage.Aboutversion0.3.0

Version0.3.0usedanimmersive-cliinsteadofshellcommands.Ifyouwanttouseit,gotothebranch0.3.0.

License

MIT©AntonioV

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论