artificery v0.2.3 Artificery.Console
A minimal logger
Link to this section Summary
Functions
Ask the user to provide data in response to a question
Updates the logger configuration with the given options
Prints a debug message, only visible when verbose mode is on
Prints an error message, and then halts the process
Terminates the process with the given status code
Prints an info message
Prints a notice
Provides a spinner while some long-running work is being done
Prints a success message
Updates a running spinner with the provided status text
Prints a warning message
Write text or iodata to standard output
Ask the user a question which requires a yes/no answer, returns a boolean
Link to this section Functions
Ask the user to provide data in response to a question
The value returned is dependent on whether a transformation is applied,
and whether blank answers are accepted. By default, empty strings will
return nil if no alternate default is supplied and either no validator
was supplied, or it returned :ok
for blank answers.
If you supply a default, instead of nil, the default will be returned. Again this only applies if a blank answer is considered valid.
You may validate answers by supplying a function (bound or captured) via
the validator: fun
option. This function will receive the raw input string
supplied by the user, and should return :ok
if the answer is valid, or
{:error, validation_error}
, where validation_error
is a string which will
be displayed to the user before asking them to answer the question again.
You may apply a transformation to answers, so that rather than getting a
string back, you get the value in a state useful for your application. You may
provide a transform via the transform: fun
option, and this will receive the
raw input string the user provided after the validator has validated the input,
if one was supplied, and if the user input was non-nil.
Supply default values with the default: term
option
Updates the logger configuration with the given options.
Prints a debug message, only visible when verbose mode is on
Prints an error message, and then halts the process
Terminates the process with the given status code
Prints an info message
Prints a notice
Provides a spinner while some long-running work is being done.
Options
- spinner: one of the spinners defined in Artificery.Console.Spinner
Example
Console.spinner "Loading...", [spinner: :simple_dots] do
:timer.sleep(5_000)
end
Prints a success message
Updates a running spinner with the provided status text
Prints a warning message
Write text or iodata to standard output.
You may optionally pass a list of styles to apply to the output, as well as the device to write to (:standard_error, or :stdio)
Ask the user a question which requires a yes/no answer, returns a boolean