🍋 acho

Acho is a Swift library to generate interactive CLI prompts.

Where does acho come from? People from Murcia, the region where I’m from use acho a lot when speaking. It’s a word that can be used for many things: grab someone’s attention, ask or complain about something, tell someone not to do something anymore. Since I found a parallelism between one of the usages of the expression, and the goal of this library, asking the user for something, I thought it’d be the perfect name for the library.

CircleCI Swift Package Manager Release Code Coverage Slack License Say Thanks! Join the community on Spectrum

Install 🛠

Swift Package Manager

Add the dependency in your Package.swift file:

let package = Package(
    name: "myproject",
    dependencies: [
        .package(url: "https://github.com/tuist/acho.git", .upToNextMajor(from: "6.2.0")),
        ],
    targets: [
        .target(
            name: "myproject",
            dependencies: ["acho"]),
        ]
)

Usage 🚀

Create an instance of Acho passing the question and the options. The options need to conform both the protocol CustomStringConvertible and Hashable:

let simulators = ["iPhone 10", "iPhone 7" ]
let acho = Acho<String>()
let simulator = acho.ask(question: "In which simulator would you like to run the app?",
                         options: simulators)

gif

Testing ✅

Acho provides an achoTesting target that you can use to easily stub the interaction with the public interface:

import achoTesting

let mock = MockAcho<String>()
let simulators = ["iPhone 10", "iPhone 7" ]
mock.stub(question: "In which simulator would you like to run the app?", items: simulators, with: "iPhone 7")

Setup for development 👩‍💻

  1. Git clone: git@github.com:tuist/acho.git
  2. Generate Xcode project with swift package generate-xcodeproj.
  3. Open acho.xcodeproj.
  4. Have fun 🤖

Open source

Tuist is a proud supporter of the Software Freedom Conservacy

Become a Conservancy Supporter!