Class: Teems::Commands::Ooo

Inherits:
Base
  • Object
show all
Includes:
OooActions, OooBuildHelpers, OooDisplay, OooSchedule, Support::TimeParsing, Support::Timezone
Defined in:
lib/teems/commands/ooo.rb

Overview

Manage out-of-office: auto-reply, status, presence, and calendar event

Constant Summary collapse

SPLIT_OOO_EMAILS =
->(raw) { raw ? raw.split(',').map(&:strip).reject(&:empty?) : [] }
OOO_OPTIONS =
{
  '--message' => ->(opts, args) { opts[:message] = args.shift },
  '--start' => ->(opts, args) { opts[:start] = args.shift },
  '--end' => ->(opts, args) { opts[:end] = args.shift },
  '--event' => ->(opts, _args) { opts[:event] = true },
  '--invite' => ->(opts, args) { opts[:invite] = SPLIT_OOO_EMAILS.call(args.shift) },
  '--no-status' => ->(opts, _args) { opts[:no_status] = true }
}.freeze
OOO_ACTIONS =
{
  'on' => :enable_ooo, 'off' => :disable_ooo,
  'config' => :show_config
}.freeze

Constants included from Support::Timezone

Support::Timezone::TIMEZONE_MAP

Instance Attribute Summary

Attributes inherited from Base

#options, #positional_args, #runner

Instance Method Summary collapse

Methods included from Support::Timezone

#detect_timezone, #short_tz_label

Constructor Details

#initialize(args, runner:) ⇒ Ooo

Returns a new instance of Ooo.



380
381
382
383
384
385
# File 'lib/teems/commands/ooo.rb', line 380

def initialize(args, runner:)
  @options = {}
  @schedule_start = UNSCHEDULED_OOO_SCHEDULE
  @schedule_end = UNSCHEDULED_OOO_SCHEDULE
  super
end

Instance Method Details

#executeObject



403
404
405
406
407
408
409
410
411
# File 'lib/teems/commands/ooo.rb', line 403

def execute
  result = validate_options
  return result if result

  auth_result = require_auth
  return auth_result if auth_result

  dispatch_action
end