Prompt

public class Prompt

Prompt class

*

  • Undocumented

    Declaration

    Swift

    public class Prompt
  • Initialize the prompt with a display style

    *

    Declaration

    Swift

    convenience public init(withStyle style: PromptStyle)

    Parameters

    withStyle

    PromptStyle

  • Asks a question that requires a String response. A valid response must be provided before the user can proceed.

    *

    Declaration

    Swift

    public func askString(question: String, message: String? = nil, block: Block? = nil) -> String

    Parameters

    question

    The question to ask the user to respond to.

    message

    Optional message to override the default message if the response is invalid.

    block

    Optional block

    Return Value

    String

  • Asks a question that requires an Int response. A valid response (i.e. an integer) must be provided before the user can proceed.

    *

    Declaration

    Swift

    public func askInt(question: String, message: String? = nil, block: Block? = nil) -> Int

    Parameters

    question

    The question to ask the user to respond to.

    message

    Optional message to override the default message if the response is invalid.

    block

    Optional block

    Return Value

    Integer

  • Asks a question that requires a Bool response. A valid response that can be converted to a boolean must be provided before the user can proceed.

    *

    Declaration

    Swift

    public func askBool(question: String, message: String? = nil, block: Block? = nil) -> Bool?

    Parameters

    question

    The question to ask the user to respond to.

    message

    Optional message to override the default message if the response is invalid.

    block

    Optional block

    Return Value

    Boolean

  • Asks a multiple choice question that requires a single response (via entering an integer). A valid response must be provided.

    *

    Declaration

    Swift

    public func askSingleChoice(text: String, choices: Choices, message: String? = nil, block: Block? = nil) -> ChoiceInfo?

    Parameters

    question

    The question to ask the user to respond to.

    choices

    An array of choices to present to the user.

    message

    Optional message to override the default message if the response is invalid.

    block

    Optional block

    Return Value

    (Index, String) - The index of the selected choice and the choice as a string