Class: OmnifocusMcp::Tools::Generators::EditItem

Inherits:
Object
  • Object
show all
Defined in:
lib/omnifocus_mcp/tools/generators/edit_item.rb

Overview

Edit a task or project in OmniFocus.

Returns an Result whose ok payload is an Edited carrying the item’s id, name, and a changed_properties string (comma-separated property names that the script reported as modified).

Defined Under Namespace

Classes: Edited

Class Method Summary collapse

Class Method Details

.call(params) ⇒ Object

Run the generated AppleScript against OmniFocus and parse the JSON result.



59
60
61
62
63
# File 'lib/omnifocus_mcp/tools/generators/edit_item.rb', line 59

def call(params)
  require_relative "../operations/edit_item"

  Operations::EditItem.call(params)
end

.generate_apple_script(params) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/omnifocus_mcp/tools/generators/edit_item.rb', line 42

def generate_apple_script(params)
  params = Params::McpBoundary.coerce(Params::EditItemParams, params)
  return missing_identifier_error if Utils::Blank.blank?(params.id, params.name)

  id = Infrastructure::AppleScript.escape(params.id.to_s)
  name = Infrastructure::AppleScript.escape(params.name.to_s)
  item_type = params.item_type.to_s

  date_pre_scripts, date_assignments = collect_date_assignments(params)

  [
    date_pre_scripts.join("\n\n"),
    Infrastructure::AppleScript.tell_document(document_body(item_type, id, name, params, date_assignments))
  ].reject(&:empty?).join("\n\n")
end