content: use AppleScript version "2.4" -- Yosemite (10.10) or later
  use scripting additions
  
  on run (argv)
  	set saveTID to text item delimiters
  	set text item delimiters to " "
  	set argType to first text item of argv
  	set argName to (text items 2 thru -1 of argv as text)
  	set text item delimiters to saveTID
  	
  	tell application "OmniFocus"
  		tell default document
  			if argType is "context" then
  				return "omnifocus:///context/" & (id of first flattened context whose name is argName)
  			else if argType is "project" then
  				return "omnifocus:///task/" & (id of first flattened project whose name is argName)
  			else if argType is "folder" then
  				return "omnifocus:///folder/" & (id of first flattened folder whose name is argName and hidden is false)
  			else if argType is "task" then
  				return "omnifocus:///task/" & (id of first flattened task whose name is argName)
  			end if
  		end tell
  	end tell
  end run
  
  on handle_string(argv)
  	set saveTID to text item delimiters
  	set text item delimiters to " "
  	set argType to first text item of argv
  	set argName to (text items 2 thru -1 of argv as text)
  	set text item delimiters to saveTID
  	
  	tell application "OmniFocus"
  		tell default document
  			if argType is "context" then
  				return [{title:"omnifocus:///context/" & (id of first flattened context whose name is argName)}]
  			else if argType is "project" then
  				return [{title:"omnifocus:///task/" & (id of first flattened project whose name is argName)}]
  			else if argType is "folder" then
  				return [{title:"omnifocus:///folder/" & (id of first flattened folder whose name is argName and hidden is false)}]
  			else if argType is "task" then
  				return [{title:"omnifocus:///task/" & (id of first flattened task whose name is argName)}]
  			end if
  		end tell
  	end tell
  end handle_string