time-handler v1.1.1
time-handler
Contents
About
Time-handler is simple console application to count time spent on events from Google Calendar. Based on official Google tutorial
Requirements
- node.js
- npm
Installation
npm i -g time-handlerUsage
You have to input some data (date range and users) to make time-handler working. There are 3 ways to input data:
- CLI arguments (highest priority)
- environment variables
.envfile (from dotenv package style) (less priority than environment variables)- app inputs (available only when variable is not defined by other way)
CLI
To run app you can use:
time-handler <args>from directory with time-handler
examples
time-handler --helptime-handler -S 2021-04-06 -e 2021-04-08 -u "user1@example.com as User1, user2@example.com"time-handler --this_month -u user@example.comoptions
--token/-T/-t- string Name of token json file--client_id- string Google API client ID--client_secret- string Google API client secret--redirect_uri- string Google API redirect_uri (first element of array)--hourly_rate- number Hourly rate (if value1money reward in summary will be skipped)--start/-S/-s- string[YYYY-MM-DD](or any string parsable to JS Date object) - Start date (of date range)--end/-E/-e- string[YYYY-MM-DD](or any string parsable to JS Date object) - End date (of date range)--users/--user/-U/-u- string Calendar ID (mostly email address), optionally you can set alias f.e.user1@example.com as User One. If you have many users use coma as separator f.euser1@example.com as User One, user2@example.com(in this case user2@example.com won't have alias)--this_month- boolean Set date range to this month (overwrite others dates)--verbose- boolean Print events summary
Environment varibles:
Every value set by CLI options can be set in environment variables also.
List of variables:
TOKENCLIENT_IDCLIENT_SECRETREDIRECT_URIHOURLY_RATESTARTENDUSERSTHIS_MONTHVERBOSE
Application inputs
If you didn't set date range or users application will ask you about missing value, you can just type value and press enter.
First run
If you run app first time, you will be asked for access token (and API's credentials if you didn't set it, (check a tutorial how to get the credentials)). To generate it follow the messages that app will print:
Authorize this app by visiting this url: https://[...]Open link, grant access to Time-handler and copy token generated by Google Calendar and paste it after:
Enter the code from that page here:New token
If you want to generate new token (for new account) you need to set new token file name. You can do it by --token CLI option or TOKEN environment variable. By default token file will be named as token.json.
Config files
Config files (.env, token.json(or named differently)) are stored in:
Windows: C:/Users/(user)/.local/share/.time-handler
Linux: /home/(user)/.local/share/.time-handler
Powershell, Git Bash, Bash:
cd $HOME/.local/share/.time-handlercmd:
cd %USERPROFILE%/.local/share/.time-handler