Module: Teems::Commands::CalOptionDefs

Defined in:
lib/teems/commands/cal.rb

Overview

Option definitions and validation for the cal command

Constant Summary collapse

SHOW_AS_VALUES =
%w[free tentative busy oof workingElsewhere].freeze
IMPORTANCE_VALUES =
%w[low normal high].freeze
SENSITIVITY_VALUES =
%w[normal personal private confidential].freeze
SPLIT_EMAILS =
->(raw) { raw ? raw.split(',').map(&:strip).reject(&:empty?) : [] }
ALL =
{
  '--days' => ->(opts, args) { opts[:days] = args.shift.to_i },
  '--week' => ->(opts, _args) { opts[:week] = true },
  '--date' => ->(opts, args) { opts[:date] = args.shift },
  '--no-interactive' => ->(opts, _args) { opts[:no_interactive] = true },
  '--comment' => ->(opts, args) { opts[:comment] = args.shift },
  '--no-send' => ->(opts, _args) { opts[:no_send] = true },
  '--start' => ->(opts, args) { opts[:start] = args.shift },
  '--end' => ->(opts, args) { opts[:end] = args.shift },
  '--duration' => ->(opts, args) { opts[:duration] = args.shift.to_i },
  '--all-day' => ->(opts, _args) { opts[:all_day] = true },
  '--location' => ->(opts, args) { opts[:location] = args.shift },
  '--body' => ->(opts, args) { opts[:body] = args.shift },
  '--html' => ->(opts, args) { opts[:html] = args.shift },
  '--attendees' => ->(opts, args) { opts[:attendees] = SPLIT_EMAILS.call(args.shift) },
  '--optional' => ->(opts, args) { opts[:optional] = SPLIT_EMAILS.call(args.shift) },
  '--room' => ->(opts, args) { opts[:rooms] = SPLIT_EMAILS.call(args.shift) },
  '--teams' => ->(opts, _args) { opts[:teams] = true },
  '--no-teams' => ->(opts, _args) { opts[:no_teams] = true },
  '--show-as' => ->(opts, args) { opts[:show_as] = args.shift },
  '--importance' => ->(opts, args) { opts[:importance] = args.shift },
  '--sensitivity' => ->(opts, args) { opts[:sensitivity] = args.shift },
  '--reminder' => ->(opts, args) { opts[:reminder] = args.shift.to_i },
  '--no-reminder' => ->(opts, _args) { opts[:no_reminder] = true },
  '--no-rsvp' => ->(opts, _args) { opts[:no_rsvp] = true },
  '--no-time-proposals' => ->(opts, _args) { opts[:no_time_proposals] = true },
  '--hide-attendees' => ->(opts, _args) { opts[:hide_attendees] = true }
}.freeze