Skip to content

Single choice

This component is a simple component that prompts the user to select a single option among many.

PropertyValue
InteractivityRequired (fails otherwise)

Demo

A gif that shows the component in action. The developer uses the key strokes up and down arrows to move their selection

API

Example

swift
enum ProjectOption: String, CaseIterable, CustomStringConvertible {
    case createTuistProject
    case useExistingXcodeProjectOrWorkspace
    case continueWithoutProject

    var description: String {
        switch self {
        case .createTuistProject:
            return "Create a Tuist project"
        case .useExistingXcodeProjectOrWorkspace:
            return "Add it to an existing Xcode project or workspace"
        case .continueWithoutProject:
            return "Continue without integrating it into a project"
        }
    }
}

let selectedOption: ProjectOption = Noora().singleChoicePrompt(
    title: "Project",
    question: "Would you like to create a new Tuist project or use an existing Xcode project?",
    description: "Tuist extend the capabilities of your projects.",
    theme: NooraTheme.tuist()
)

Options

AttributeDescriptionRequiredDefault value
titleThe title of the prompt.No
questionThe question that the user will answer.Yes
descriptionA description that provides more context about the question.No
collapseOnSelectionWhether the prompt should collapse after the user selects an option.Notrue

Released under the MIT License.