Skip to content

Instantly share code, notes, and snippets.

@kaleocheng
Last active June 6, 2018 13:10
Show Gist options
  • Save kaleocheng/f0bbd7cc256d74dcef59783c790bff5b to your computer and use it in GitHub Desktop.
Save kaleocheng/f0bbd7cc256d74dcef59783c790bff5b to your computer and use it in GitHub Desktop.
#!/usr/bin/swift
# How to run:
# swiftc dict.swift
# ./dict hello
import Foundation
if (CommandLine.argc < 2) {
print("Usage: dictionary word")
}else{
let argument = CommandLine.arguments[1]
let result = DCSCopyTextDefinition(nil, argument as CFString, CFRangeMake(0, argument.count))?.takeRetainedValue() as String?
print(result ?? "")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment