Functions
The following functions are available globally.
-
Presents a user with a menu of items to choose from
Declaration
Swift
public func choose(prompt: String, choices: String...) -> StringParameters
promptThe menu prompt message
choicesList of choices
Return Value
The user selected item
-
Presents a user with a menu of items to choose from
Declaration
Swift
public func choose<T>(costumizationBlock: (ChooseSettings<T> -> Void)) -> TParameters
costumizationBlockClosure to be called with a ChooseSettings, changes to the settings are reflected to the prompt
Return Value
The user selected item
-
Presents a user with a menu of items to choose from
Declaration
Swift
public func choose<T>(prompt: String, type: T.Type, costumizationBlock: (ChooseSettings<T> -> Void)) -> TParameters
promptThe menu prompt message
typeThe value type to be expected from the user
costumizationBlockClosure to be called with a ChooseSettings, changes to the settings are reflected to the prompt
Return Value
The user selected item
-
Presents a user with a menu of items to choose from
Declaration
Swift
public func choose<T>(type: T.Type, costumizationBlock: (ChooseSettings<T> -> Void)) -> TParameters
typeThe value type to be expected from the user
costumizationBlockClosure to be called with a ChooseSettings, changes to the settings are reflected to the prompt
Return Value
The user selected item
-
Displays a yes/no prompt to the user
Declaration
Swift
public func agree(prompt: String) -> BoolParameters
promptThe prompt to display
Return Value
the user decision
-
Display a promt to the user
Declaration
Swift
public func ask(prompt: String, customizationBlock: (AskSettings<String> -> Void)? = nil) -> StringParameters
promptThe message to display
customizationBlockThe block to costumize the prompt before displaying
Return Value
The string enters from the user
-
Display a promt to the user
discussion: If the user enters a wrong type, ask will keep prompting until a correct value has been entered
Declaration
Swift
public func ask<T: ArgConvertibleType>(prompt: String, type: T.Type, customizationBlock: (AskSettings<T> -> Void)? = nil) -> TParameters
promptThe message to display
typeThe value type to be expected from the user
customizationBlockThe block to costumize the prompt before displaying
Return Value
The string casted to the type requested
-
Executes a command and captures its output
Declaration
Swift
public func run(command: String, args: String...) -> RunResultsParameters
commandthe command to execute
argsthe parameters to pass to the command
Return Value
RunResults describing the command results
-
Executes a command and captures its output
Declaration
Swift
public func run(command: String, argsString: String) -> RunResultsParameters
commandthe command to execute
argStringthe arguments passed as a single string
Return Value
RunResults describing the command results
-
Executes a command and captures its output
Declaration
Swift
public func run(command: String, args: [String]) -> RunResultsParameters
commandthe command to execute
argsthe parameters to pass to the command
Return Value
RunResults describing the command results
-
Executes a command and captures its output
Declaration
Swift
public func run(command: String, settingsBlock: (RunSettings -> Void)) -> RunResultsParameters
commandthe command to execute
settingsBlockblock that receives the settings to costumize the behavior of run
Return Value
RunResults describing the command results
-
Executes a command and captures its output
Declaration
Swift
public func run(command: String, args: [String], settings: (RunSettings -> Void)) -> RunResultsParameters
commandthe command to execute
argsthe parameters to pass to the command
settingsBlockblock that receives the settings to costumize the behavior of run
Return Value
RunResults describing the command results
-
Execute a command in interactive mode, output won’t be captured
Declaration
Swift
public func runWithoutCapture(command: String) -> IntParameters
commandthe command to execute
Return Value
executed command exit code
View on GitHub
Functions Reference