1
1
mirror of https://github.com/nsomar/Swiftline.git synced 2024-08-15 16:40:24 +03:00
Swiftline/Examples/ChooseExample.swift
2015-11-12 08:54:15 +00:00

31 lines
878 B
Swift
Executable File

#!/usr/bin/env xcrun swift -F ./Rome/ -framework Swiftline
import Swiftline
let choice = choose("Whats your favorite programming language? ",
choices: "Swift", "Objective C", "Ruby", "Python", "Java :S")
print("You choosed \(choice)")
// Choose with Int result
let choice2 = choose("Whats your favorite programming language? ", type: Int.self) { settings in
settings.addChoice("Swift") { 42 }
settings.addChoice("Objective C") { 20 }
}
print("You choosed \(choice2)")
// Customize prompt
let choice3 = choose("Whats your favorite programming language? ", type: String.self) { settings in
//choice value will be set to GOOD
settings.addChoice("Swift") { "GOOD" }
//choice value will be set to BAD
settings.addChoice("Java") { "BAD" }
settings.index = .Letters
settings.indexSuffix = " ----> "
}
print("Your choice is \(choice3)")