Created
March 29, 2018 17:52
-
-
Save kach/d3c5941a09e6e9f6b6aab4b287c920ed to your computer and use it in GitHub Desktop.
Command-line word lookup based on Apple's built-in dictionaries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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