gcal
GoogleCaledarcommadlietoolforNode.js
Programmaticevetlistig,isertorbulkisertmadeeasy:
$gcalisert'Partytomorrowfrom3pmto5pm'Party:2017-09-08T15:00:00+09:00~2017-09-08T17:00:00+09:00https://www.google.com/caledar/evet?eid=amNpMWE5cjg2bG802s0Nmg1ZWlqcW01OXMgdG9rYWdlcm9oQG0$echo\'[{"caledarId":"primary","resource":{"summary":"Party","start":{"dateTime":"2017-09-08T20:00"},"ed":{"dateTime":"2017-09-08T22:00"}}},{"caledarId":"primary","resource":{"summary":"Partyagai","start":{"dateTime":"2017-09-08T22:00"},"ed":{"dateTime":"2017-09-08T23:30"}}}]'\>evets.jso$gcalbulk-eevets.jsoEvetisertedid:gif4hl86kgt7bmgq2ojvteqe2osummary:PartyhtmlLik:https://www.google.com/caledar/evet?eid=Z2lmNGhsODZrZ3Q3Ym1cTJvaZ0ZXFlMm8gdG9rYWdlcm9oQG0Evetisertedid:blrrb8kbrih3pq9m10slii8acsummary:PartyagaihtmlLik:https://www.google.com/caledar/evet?eid=YmxycmI4a2JyaWgzcHE5bW4xMHNsaWk4YWMgdG9rYWdlcm9oQG0$gcallistUpcomigevets(2017-09-07T00:00:00+09:00~2017-09-07T23:59:59+09:00)2017-09-0720:00-MyfavoriteTVshow2017-09-0722:30-Preparetomorrow'smeetigstuffIstallatioIstallitasaglobalmodule:
pmistall-ggcalAutheticatioAuthorizatioadautheticatioisdoewithOAuth2.0.
Ok,thiswilltakeoly2miutes:
1)GetyourprojectcredetialsYouwilleedafilewithyourcredetials:clietID,clietsecretadredirectURI.ThiscabeobtaieditheDeveloperCosole:
GotoyourprojectClickiCredetialsClickCreatecredetials→OAuthclietID(ApplicatiotypemustbeOther)DowloadtheJSONfile2)GeeratecosetpageURLOcewegotthecredetialswemustgeerateacosetpageURL.
$gcalgeerateUrl(Bydefaultthecredetialswillbesearchediyourhomedirectoryudertheamecliet_secret.jso).
Thepagewillpromptyoutoauthorizeaccess,followtheistructios.
3)Getthetoke!Withthecodewegotthroughtheauthorizatiopage,wecaobtaiatokeadstoreitiourmachie.
$gcalstoreToke<code>(Bydefaultthetokeisstorediyourhomefolderudertheamecaledar_api_toke.jso).
NOTE:Thetokewillexpiryafteroehour,butarefresh_tokeisicludedaswell,allowigtheapptorefreshautomaticallythetokeeachtimeit'sused.
Withthiswearegoodtogo.Thestoredtokeadcredetialsfileswillberequiredfromowotousethistool.
UsageListListtodayevets:
$gcallistListevetsusigaturallaguage(poweredbySherlock):
$gcallisttomorrow$gcallist'from03/23/2017to03/27/2017'$gcallist'fromMarch23thto27th'OrwithspecificISOdates:
$gcallist-f2017-03-23-t2017-03-27IsertIsertevetsusigaturallaguage:
$gcalisert'Partytomorrowfrom3pmto5pm'Isertevetsspecifyigtheparameters:
$gcalisert-s'Party'-d2017-03-23-t15:00-D2hBulkIsertBulkisertpassiga.jsor.jsofile:
evets.jso
[{"caledarId":"primary","resource":{"summary":"HavigcoffeewithOkuyasu","locatio":"MorioCity","descriptio":"I'motveryimagiativeowsosomedescriptiogoeshere","start":{"dateTime":"2017-09-08T09:00:00"},"ed":{"dateTime":"2017-09-08T10:00:00"}}},{"caledarId":"primary","resource":{"summary":"DefeatDio","locatio":"179OroubaSt,Cairo","descriptio":"DioisabadboysoIeedtokickhisassasap","start":{"date":"1987-06-01"},"ed":{"date":"1987-06-12"}}}]$gcalbulk-e./evets.jsoUsiga.jsfilecabeusefulforrelativedatesadmore:
evets.js
costtoday=ewDate();today.setHours('17','00','00');costtomorrow=ewDate(today.getTime()+1000*60*60*24);module.exports=[{"caledarId":"primary","resource":{"summary":`Release`,"start":{"dateTime":today.toISOStrig()},"ed":{"dateTime":today.toISOStrig()}}},{"caledarId":"primary","resource":{"summary":"Release","start":{"dateTime":tomorrow.toISOStrig()},"ed":{"dateTime":tomorrow.toISOStrig()}}}];$gcalbulk-e./evets.jsTheavailablepropertiesarelistedhere.
OverwritigdefaultcofigUsigtheoptio-C<file>thedefaultcofigcabeoverwritte.Thisfilemustbe.jsor.jso.Cofigurableoptiosarelocatedi./cof.js.
Example:
/somepath/cofig.jso
{"CRED_PATH":"/my/secret/path/credetials.jso","TOKEN_PATH":"/my/secret/path/toke.jso"}$gcal-C/somepath/cofig.jsogeerateUrlDoigthisyoucastoreyourcredetialfileswhereveryouwat.
APIUsethehelpcommad.Moredetailswillbeaddedsoo.
$gcalhelp
Usage:gcal[-C<file>][cmd][--debug]OPTIONS-C,--cofig<file>--debugCommads:list[<term>|[-f<date|datetime>][-t<date|datetime>]][-i]Listevets.Bydefaultitshowstodayevets(executedwithoutargumets).OPTIONS-f,--from<date|datetime>-t,--to<date|datetime>-i,--show-idisert<term>|-s<summary>-d<date>[-t<time>][-D<duratio>]Isertevets.<term>isspecifiediaturallaguage,icaseit'sotspecified,-sad-daremadatory.OPTIONS-s,--summary<summary>-d,--date<date>-t,--time<time>-D,--duratio<duratio>bulk-e<file>Bulkisertofevets.Filecabe.jsoor.js.OPTIONS-e,--evets<file>geerateUrlGeeratecosetpageURL.Iordertoworkcliet_secret.jsmustbeiyourhomefolder.storeToke<code>StoreTokeiyourhomefolder.helpShowthishelppage.Aboutversio0.3.0Versio0.3.0usedaimmersive-cliisteadofshellcommads.Ifyouwattouseit,gotothebrach0.3.0.
LiceseMIT©AtoioV
评论