UserIO

Provides various utilities: - Program-wide configuration via UserIO.configure - Logging, including debug-only and verbose-only logging via logf, debugf, and verbosef - Logging helpers, for example logTracef, debugInfof, and verboseErrorf. - Easily getting input from the user via getInput, getInputNonEmptyString, getInputFromList, and more.

final static
class UserIO {}

Members

Aliases

debugException
alias debugException = exception!debugErrorf

Helper functions for debugf, to easily use a specific log level.

logException
alias logException = exception!logErrorf

Helper functions for logf, to easily use a specific log level.

verboseException
alias verboseException = exception!verboseErrorf

Helper functions for verbosef, to easily use a specific log level.

Static functions

configure
UserIOConfigBuilder configure()

Configure the settings for UserIO, can be called multiple times.

debugCriticalf
void debugCriticalf(char[] format, Args args)
debugErrorf
void debugErrorf(char[] format, Args args)
debugFatalf
void debugFatalf(char[] format, Args args)
debugInfof
void debugInfof(char[] format, Args args)

Helper functions for debugf, to easily use a specific log level.

debugTracef
void debugTracef(char[] format, Args args)
debugWarningf
void debugWarningf(char[] format, Args args)

Helper functions for debugf, to easily use a specific log level.

debugf
void debugf(char[] format, LogLevel level, Args args)

Variant of UserIO.logf that only shows output in non-release builds.

exception
void exception(Exception ex)

Logs an exception, using the given LogFunc, as an error.

getInput
T getInput(string prompt)

Gets input from the user, and uses the given ArgBinder (or the default one, if one isn't passed) to convert the string to a T.

getInputCatchExceptions
T getInputCatchExceptions(string prompt, void delegate(Ex) onException)

A variant of UserIO.getInput that'll constantly prompt the user until they enter a value that doesn't cause an exception (of type Ex) to be thrown by the Binder.

getInputFromList
T getInputFromList(string prompt, T[] list, string promptPostfix)

A variant of UserIO.getInput that'll constantly prompt the user until they enter a value from the given list.

getInputNonEmptyString
string getInputNonEmptyString(string prompt)

A variant of UserIO.getInput that'll constantly prompt the user until they enter a non-null, non-whitespace-only string.

log
void log(char[] output, LogLevel level)

Logs the given output to the console, as long as level is >= the configured minimum log level.

logCriticalf
void logCriticalf(char[] format, Args args)
logErrorf
void logErrorf(char[] format, Args args)
logFatalf
void logFatalf(char[] format, Args args)
logInfof
void logInfof(char[] format, Args args)

Helper functions for logf, to easily use a specific log level.

logTracef
void logTracef(char[] format, Args args)
logWarningf
void logWarningf(char[] format, Args args)

Helper functions for logf, to easily use a specific log level.

logf
void logf(char[] fmt, LogLevel level, Args args)

Variant of UserIO.log that uses std.format.format to format the final output.

moveCursorDownByLines
void moveCursorDownByLines(size_t lineCount)

Moves the console's cursor down and moves the cursor to the start of that line.

moveCursorUpByLines
void moveCursorUpByLines(size_t lineCount)

Moves the console's cursor up and moves the cursor to the start of that line.

verboseCriticalf
void verboseCriticalf(char[] format, Args args)
verboseErrorf
void verboseErrorf(char[] format, Args args)
verboseFatalf
void verboseFatalf(char[] format, Args args)
verboseInfof
void verboseInfof(char[] format, Args args)

Helper functions for verbosef, to easily use a specific log level.

verboseTracef
void verboseTracef(char[] format, Args args)
verboseWarningf
void verboseWarningf(char[] format, Args args)

Helper functions for verbosef, to easily use a specific log level.

verbosef
void verbosef(char[] format, LogLevel level, Args args)

Variant of UserIO.logf that only shows output if UserIOConfigBuilder.useVerboseLogging is set to true.

Meta