Last active
November 19, 2015 11:45
-
-
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/
This file contains hidden or 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
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