Skip to content

Instantly share code, notes, and snippets.

@clmntcrl
Last active November 19, 2015 11:45
Show Gist options
  • Save clmntcrl/2bc820d4552f34a7c81a to your computer and use it in GitHub Desktop.
Save clmntcrl/2bc820d4552f34a7c81a to your computer and use it in GitHub Desktop.
Scripting in Swift - Commands #1. Full post: http://clmntcrl.io/blog/scripting-in-swift-commands/
enum Command: String {
case Command1, Command2
}
func main(args: [String]) {
guard let arg1 = args.first,
command = Command(rawValue: arg1.capitalizedString) else {
// Maybe it would be a good thing to print some help...
return
}
switch command {
case .Command1: // ...
case .Command2: // ...
}
}
let args = Process.arguments.dropFirst()
main(args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment