-
Notifications
You must be signed in to change notification settings - Fork 99
Open
Description
I know it is possible to provide default values when prompting the user for input. See below:
let level = ask("Choose level: ", type: Int.self) { settings in
settings.defaultValue = 1
}Unfortunately this value is only used in preparedItem() which is not called anywhere. When the user does not provide an input he gets the message to enter a valid integer despite the fact I chose a default value.
public class AskSettings<T: ArgConvertibleType> {
/// Default value to set incase the user entered a blank
public var defaultValue: T?
...
func preparedItem(originalString string: String) -> T {
if string.isEmpty && defaultValue != nil {
return defaultValue!
}
return T.fromString(string)!
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels