flycal-cli
A command-line tool to access and search Google Calendar events. Connect your Google account, choose a default calendar, and search events with flexible date ranges and text filters.
Requirements
- Ruby 3.1 or later
- A Google Cloud project with Calendar API enabled
Installation
gem install flycal-cliOr add to your Gemfile:
gem "flycal-cli"Then run bundle install.
Setup
Before using flycal, you need OAuth credentials from Google Cloud Console:
- Go to Google Cloud Console - Credentials
- Create a project or select an existing one
- Enable the Google Calendar API (APIs & Services → Library → search for "Google Calendar API")
- Create Desktop app credentials (OAuth 2.0 Client IDs)
- Add this URI as an authorized redirect:
http://127.0.0.1:9292/oauth2callback - Download the JSON file and save it as
~/.flycal/credentials.json
Commands
login
Connect to your Google account. Opens a browser for OAuth authentication when not yet connected.
flycal loginIf already connected, the command reports the current status and suggests running flycal calendars to set the default calendar.
logout
Disconnect from your Google account and remove stored tokens.
flycal logoutcalendars
List available calendars and set the default one. Uses an interactive scrollable menu (arrow keys to navigate, type to filter).
flycal calendarsThe default calendar is used by the search command when no calendar is specified.
search
Search for events in your calendar(s). Supports flexible date ranges and text filtering.
flycal search
flycal search --in 30days --description placeholder
flycal search -f 2025-03-01 -t 2025-03-31 -c "Work"
flycal search -i 2months -d placeholderOptions:
-
--from/-f— Start date/time. Default: midnight of current day. Format:2025-01-01or2025-01-01T09:00 -
--to/-t— End date/time. Default: 23:59 of the 30th day from today. Format: same as--from -
--in/-i— Duration from--from, overrides--to. Format:30days,48hours,2months,1year(no space). With space use quotes:--in "30 days" -
--calendar/-c— Calendar name or ID. Default: calendar set viaflycal calendars -
--description/-d— Filter events by text. Matches events where the string appears in title or description (case-insensitive, contains)
Time range behavior:
- If neither
--fromnor--tois given: searches from today at midnight to 23:59 of the 30th day from today - If
--inis given:--tois ignored; the end time is computed from--fromplus the duration - Examples:
--in 30days,--in 48hours,--in 1months,--in 1year
Output:
Each event is printed as: Calendar | Start | End | Title
The summary shows:
- From and To dates used
- Number of events found
- Total time occupied (hours, minutes, and working days based on 8-hour days)
For time frames longer than 7 days, a weekly breakdown is added (week number, start/end dates, hours, working days per week). For time frames longer than 30 days, a monthly breakdown is shown instead (month number, month name, hours, working days per month).
Configuration
Data is stored in ~/.flycal/:
| File | Purpose |
|---|---|
config.yml |
Default calendar ID and other settings |
credentials.json |
OAuth credentials (created manually from Google Cloud Console) |
tokens.yml |
Access tokens (managed automatically) |
Publishing to RubyGems
First release
- Create an account at rubygems.org if needed
- Update
flycal-cli.gemspecwith your author, email, and homepage - Build and push:
gem build flycal-cli.gemspec
gem push flycal-cli-0.1.0.gemSubsequent releases
- Update the version in
lib/flycal_cli/version.rb - Build and push:
gem build flycal-cli.gemspec
gem push flycal-cli-X.Y.Z.gem- Optionally tag and push:
git tag vX.Y.Z
git push origin vX.Y.ZUsing rake release
With bundler/gem_tasks in your Rakefile:
bundle exec rake releaseThis builds the gem, pushes to RubyGems, and can handle git tagging and pushing.
License
MIT