Skip to content

Instantly share code, notes, and snippets.

@kach
Created March 29, 2018 17:52
Show Gist options
  • Save kach/d3c5941a09e6e9f6b6aab4b287c920ed to your computer and use it in GitHub Desktop.
Save kach/d3c5941a09e6e9f6b6aab4b287c920ed to your computer and use it in GitHub Desktop.
Command-line word lookup based on Apple's built-in dictionaries
import Foundation
import CoreServices
if CommandLine.argc < 2 { exit(1) }
let word = CommandLine.arguments[1] as CFString
let rang = CFRangeMake(0, CFStringGetLength(word)) //DCSGetTermRangeInString(nil, word, 0)
let defn = DCSCopyTextDefinition(nil, word, rang)
if defn != nil { print(defn!.takeUnretainedValue() as String) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment