Skip to content

Instantly share code, notes, and snippets.

@monkeydom
Created June 10, 2014 18:41
Show Gist options
  • Save monkeydom/e04eea0535b6b2e79fe6 to your computer and use it in GitHub Desktop.
Save monkeydom/e04eea0535b6b2e79fe6 to your computer and use it in GitHub Desktop.
dom@domair:~/bin$ cat swift-optparser.swift
#!/usr/bin/env xcrun swift -i
// add e.g. -sdk '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk'
// to be able to import Cocoa Frameworks
var argumentArray = Array<String>()
for index in 0..Int(C_ARGC) {
argumentArray.append(String.fromCString(C_ARGV[index]))
}
println("hello world")
println("\(Process.arguments)")
println("\(argumentArray)")
dom@domair:~/bin$ ./swift-optparser.swift some parameter i like
<unknown>:0: error: no such file or directory: 'some'
<unknown>:0: error: no such file or directory: 'parameter'
<unknown>:0: error: no such file or directory: 'i'
<unknown>:0: error: no such file or directory: 'like'
dom@domair:~/bin$ ./swift-optparser.swift
hello world
[-i, ./swift-optparser.swift, -enable-objc-attr-requires-objc-module, -target, x86_64-apple-darwin13.2.0, -module-name, main, -color-diagnostics]
[-i, ./swift-optparser.swift, -enable-objc-attr-requires-objc-module, -target, x86_64-apple-darwin13.2.0, -module-name, main, -color-diagnostics]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment