<commit_before>require 'json'
require 'uri'
require 'yaml'
require 'net/https'

class GoohubCLI < Clian::Cli
  desc "share CALENDAR_ID EVENT_ID FILTER ACTION", "Filtering event by EVENT_ID, and share it by action"
  long_desc <<-LONGDESC
FILTER is `no_filter`, `summary_delete`, `created_delete`, or `location_delete` (default is `no_filter`)

ACTION is `stdout`, `calendar:POST_CALENDAR_ID`, or `slack` (default is `stdout`)

If you use `slack` in ACTION, you need get incoming-webhook url and set it in settings.yml
LONGDESC

  def share(calendar_id, event_id, filter = "no_filter", action = "stdout")
    event = client.get_event(calendar_id, event_id)
    parse_event(event)
    apply_filter(filter)
    apply_action(action)
  end

  private

  def parse_event(event)
    @sentence_items = {}
    @sentence_items["summary"] =    event.summary
    @sentence_items["id"] =         event.id
    @sentence_items["created"] =    event.created
    @sentence_items["kind"] =       event.kind
    @sentence_items["organized"] =  event.organizer.display_name
    @sentence_items["start_time"] = event.start.date_time<commit_msg>Change filter and action to option<commit_after>require 'json'
require 'uri'
require 'yaml'
require 'net/https'

class GoohubCLI < Clian::Cli
  desc "share CALENDAR_ID EVENT_ID", "Filtering event by EVENT_ID, and share it by action"
  option :filter, :default => "no_filter", :desc => "specify filter to apply"
  option :action, :default => "stdout", :desc => "specify action to apply"
  long_desc <<-LONGDESC
FILTER is `no_filter`, `summary_delete`, `created_delete`, or `location_delete`

ACTION is `stdout`, `calendar:POST_CALENDAR_ID`, or `slack`

If you use `slack` in ACTION, you need get incoming-webhook url and set it in settings.yml
LONGDESC

  def share(calendar_id, event_id)
    filter = options[:filter]
    action = options[:action]
    event = client.get_event(calendar_id, event_id)
    parse_event(event)
    apply_filter(filter)
    apply_action(action)
  end

  private

  def parse_event(event)
    @sentence_items = {}
    @sentence_items["summary"] =    event.summary
    @sentence_items["id"] =         event.id
    @sentence_items["created"] =    event.created
    @sentence_items["kind"] =       event.kind
    @sentence_items["organized"] =  event.organizer.display_name
    @sentence_items["start_time"] = event.start.date_time
{'fraction_non_alphanumeric': 0.11606391925988226, 'fraction_numerical': 0.0, 'mean_word_length': 4.481566820276497, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '939845', 'n_tokens_mistral': 784, 'n_tokens_neox': 754, 'n_words': 202}