Class: Gmeet::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/utilities/gmeet/cli.rb

Direct Known Subclasses

Mcpeasy::GmeetCommands

Instance Method Summary collapse

Instance Method Details

#meetingsObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/utilities/gmeet/cli.rb', line 29

def meetings
  result = tool.list_meetings(
    start_date: options[:start_date],
    end_date: options[:end_date],
    max_results: options[:max_results],
    calendar_id: options[:calendar_id] || "primary"
  )
  meetings = result[:meetings]

  if meetings.empty?
    puts "🎥 No Google Meet meetings found for the specified date range"
  else
    puts "🎥 Found #{result[:count]} Google Meet meeting(s):"
    meetings.each_with_index do |meeting, index|
      puts "   #{index + 1}. #{meeting[:summary] || "No title"}"
      puts "      Start: #{format_datetime(meeting[:start])}"
      puts "      End: #{format_datetime(meeting[:end])}"
      puts "      Description: #{meeting[:description]}" if meeting[:description]
      puts "      Location: #{meeting[:location]}" if meeting[:location]
      puts "      Attendees: #{meeting[:attendees].join(", ")}" if meeting[:attendees]&.any?
      puts "      Meet Link: #{meeting[:meet_link]}"
      puts "      Calendar Link: #{meeting[:html_link]}"
      puts
    end
  end
rescue RuntimeError => e
  warn "❌ Failed to list meetings: #{e.message}"
  exit 1
end

#search(query) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/utilities/gmeet/cli.rb', line 94

def search(query)
  result = tool.search_meetings(
    query,
    start_date: options[:start_date],
    end_date: options[:end_date],
    max_results: options[:max_results]
  )
  meetings = result[:meetings]

  if meetings.empty?
    puts "🔍 No Google Meet meetings found matching '#{query}'"
  else
    puts "🔍 Found #{result[:count]} Google Meet meeting(s) matching '#{query}':"
    meetings.each_with_index do |meeting, index|
      puts "   #{index + 1}. #{meeting[:summary] || "No title"}"
      puts "      Start: #{format_datetime(meeting[:start])}"
      puts "      End: #{format_datetime(meeting[:end])}"
      puts "      Description: #{meeting[:description]}" if meeting[:description]
      puts "      Location: #{meeting[:location]}" if meeting[:location]
      puts "      Meet Link: #{meeting[:meet_link]}"
      puts "      Calendar Link: #{meeting[:html_link]}"
      puts
    end
  end
rescue RuntimeError => e
  warn "❌ Failed to search meetings: #{e.message}"
  exit 1
end

#testObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/utilities/gmeet/cli.rb', line 10

def test
  response = tool.test_connection

  if response[:ok]
    puts "✅ Successfully connected to Google Calendar"
    puts "   User: #{response[:user]} (#{response[:email]})"
  else
    warn "❌ Connection test failed"
  end
rescue RuntimeError => e
  puts "❌ Failed to connect to Google Calendar: #{e.message}"
  exit 1
end

#upcomingObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/utilities/gmeet/cli.rb', line 62

def upcoming
  result = tool.upcoming_meetings(
    max_results: options[:max_results],
    calendar_id: options[:calendar_id] || "primary"
  )
  meetings = result[:meetings]

  if meetings.empty?
    puts "🎥 No upcoming Google Meet meetings found in the next 24 hours"
  else
    puts "🎥 Found #{result[:count]} upcoming Google Meet meeting(s):"
    meetings.each_with_index do |meeting, index|
      puts "   #{index + 1}. #{meeting[:summary] || "No title"}"
      puts "      Start: #{format_datetime(meeting[:start])} (#{meeting[:time_until_start]})"
      puts "      End: #{format_datetime(meeting[:end])}"
      puts "      Description: #{meeting[:description]}" if meeting[:description]
      puts "      Location: #{meeting[:location]}" if meeting[:location]
      puts "      Attendees: #{meeting[:attendees].join(", ")}" if meeting[:attendees]&.any?
      puts "      Meet Link: #{meeting[:meet_link]}"
      puts "      Calendar Link: #{meeting[:html_link]}"
      puts
    end
  end
rescue RuntimeError => e
  warn "❌ Failed to list upcoming meetings: #{e.message}"
  exit 1
end

#url(event_id) ⇒ Object



125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/utilities/gmeet/cli.rb', line 125

def url(event_id)
  result = tool.get_meeting_url(event_id, calendar_id: options[:calendar_id] || "primary")

  puts "🎥 #{result[:summary] || "Meeting"}"
  puts "   Start: #{format_datetime(result[:start])}"
  puts "   End: #{format_datetime(result[:end])}"
  puts "   Meet Link: #{result[:meet_link]}"
  puts "   Event ID: #{result[:event_id]}"
rescue RuntimeError => e
  warn "❌ Failed to get meeting URL: #{e.message}"
  exit 1
end