Skip to content

skunkrocker/SwiftAsk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwiftAsk

Simple Swift library for asking the user the hard questions on the Command line.

Instalation

import PackageDescription

let package = Package(
        name: "Your Package",
        dependencies: [
            .package(url: "https://github.com/skunkrocker/SwiftAsk.git", from: "1.0.2")
        ]
)

Usage

Ask the question and execute the block only when positive answer is given.

let question = Question(question: "Wonna play game", color: .blue)
ask(question, .yes_or_no) {
    say("Glad you agree!!".bold)
}

Ask clear yes no questions.

let answer = askYesNo("Do you like cats?", color: .yellow)
if answer {
    say("Yes they are cute.")
} else {
    say("I see, you are more of a dog person.")
}

Ask questions in different colors and use different types of [Y]es [N]o question.

let question = Question(question: "Wonna play game", color: .cyan)
ask(question, .yes_no_brackets) { answer in
    say("You answered with: \(answer)")
}

Choose your own code style how to use it.

let question = Question(question: "Wonna play game", color: .cyan)
let answer = ask(question, .yes_no_brackets)
say("You answered with: \(answer)")

About

Command Line Input reading for Swift

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages