Latest 0.1.2
License MIT
Platforms osx 10.11, requires ARC

Prompter – Capture Command Line Input with Swift

CI Status

Prompter is lightweight Swift 2+ library that greatly simplifies capturing user input for command line (cli) applications on OSX and Linux.

Specifically, it allows you to prompt the user for input and validate that responses are (currently) String, Int, Bool, or a valid single choice from a given list.


Swift Package Manager

To add Prompter via the SPM, add the following to your Package.swift file:

let package = Package(
    name: "YourPackageName"
    dependencies: [
        .Package(url: "", majorVersion: 1),


Prompter is available through CocoaPods.

To install it, simply add the following line to your Podfile:

pod "Prompter"



This library is well documented. View the documentation.


Each ask method includes the following arguments:

  • question – required
  • message – optional string to override the default validation message
  • block – an optional closure that is called on success

import Prompter

let prompt = Prompt()

//Prompt the user for a string input
let name = prompt.askString("What is your name?",
  message: "This is an optional validation message!") { string in
  //this is an optional block

//Prompt the user for a string input
let age = prompt.askInt("How old are you?")

//Prompt the user for a Boolean response
//y, Y, Yes, yes, t, True, 1 are all true etc
let age = prompt.askBool("Do you like beans")

//Ask the user to select from a list of choices
let choices = ["beans", "apples"]
let age = prompt.askChoice("Which of these do you prefer",
  choices: choices) { (index, string) in
    print(index, string)
    //0, beans


  • askDate
  • askMultiple
  • initWithStyle


Run the tests using xctool:

xctool -workspace Prompter.xcworkspace -scheme Prompter test


Matthew Clarkson from Hilenium @matt_clarkson


Prompter is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "Prompter",
    "version": "0.1.2",
    "summary": "Light weight helpers for developing interactive command line (cli) scripts in Swift.",
    "license": {
        "type": "MIT",
        "file": ""
    "authors": {
        "Matthew Clarkson": "[email protected]"
    "social_media_url": "",
    "platforms": {
        "osx": "10.11"
    "requires_arc": true,
    "source": {
        "git": "",
        "tag": "0.1.2"
    "homepage": "",
    "source_files": "Source/*.{swift}",
    "documentation_url": ""

Pin It on Pinterest

Share This