class Athena::Console::Style::Athena
- Athena::Console::Style::Athena
- Athena::Console::Style::Output
- Reference
- Object
Overview
Default implementation of ACON::Style::Interface that provides a slew of helpful methods for formatting output.
Uses ACON::Helper::AthenaQuestion to improve the appearance of questions.
protected def execute(input : ACON::Input::Interface, output : ACON::Output::Interface) : ACON::Command::Status
style = ACON::Style::Athena.new input, output
style.title "Some Fancy Title"
# ...
ACON::Command::Status::SUCCESS
end
Defined in:
style/athena.crConstructors
Instance Method Summary
-
#ask(question : String, default : _)
Helper method for asking
ACON::Questionquestions. -
#ask(question : ACON::Question::Base)
:inherit:
-
#ask_hidden(question : String)
Helper method for asking hidden
ACON::Questionquestions. - #block(messages : String | Enumerable(String), type : String | Nil = nil, style : String | Nil = nil, prefix : String = " ", padding : Bool = false, escape : Bool = true) : Nil
-
#caution(messages : String | Enumerable(String)) : Nil
:inherit:
-
#choice(question : String, choices : Indexable | Hash, default = nil)
Helper method for asking
ACON::Question::Choicequestions. -
#comment(messages : String | Enumerable(String)) : Nil
:inherit:
-
#confirm(question : String, default : Bool = true) : Bool
Helper method for asking
ACON::Question::Confirmationquestions. -
#create_progress_bar(max : Int32 | Nil = nil) : ACON::Helper::ProgressBar
Creates and returns an
ACON::Helper::ProgressBar, optionally with the provided max amount of steps. -
#create_table : ACON::Helper::Table
Creates and returns an Athena styled
ACON::Helper::Tableinstance. -
#definition_list(*rows : String | ACON::Helper::Table::Separator | Enumerable(Tuple(K, V))) : Nil forall K, V
Formats a list of key/value pairs horizontally.
-
#error(messages : String | Enumerable(String)) : Nil
:inherit:
-
#error_style : self
Returns a new instance of
selfthat outputs to the error output. -
#horizontal_table(headers : Enumerable, rows : Enumerable) : Nil
Sames as
#table, but horizontal -
#info(messages : String | Enumerable(String)) : Nil
:inherit:
-
#listing(elements : Enumerable) : Nil
Formats and prints a bulleted list containing the provided elements.
-
#listing(*elements : String) : Nil
:inherit:
-
#new_line(count : Int32 = 1) : Nil
:inherit:
-
#note(messages : String | Enumerable(String)) : Nil
:inherit:
-
#print(messages : String | Enumerable(String), verbosity : ACON::Output::Verbosity = :normal, output_type : ACON::Output::Type = :normal) : Nil
:inherit:
-
#progress_advance(by step : Int32 = 1) : Nil
Advances the internal
ACON::Helper::ProgressBarby the provided amount of steps. -
#progress_finish : Nil
Completes the internal
ACON::Helper::ProgressBar. - #progress_iterate(enumerable : Enumerable(T), max : Int32 | Nil = nil, & : T -> Nil) : Nil forall T
-
#progress_start(max : Int32 | Nil = nil) : Nil
Starts an internal
ACON::Helper::ProgressBar, optionally with the provided max amount of steps. -
#puts(messages : String | Enumerable(String), verbosity : ACON::Output::Verbosity = :normal, output_type : ACON::Output::Type = :normal) : Nil
:inherit:
-
#section(message : String) : Nil
Creates a section header with the provided message.
-
#success(messages : String | Enumerable(String)) : Nil
:inherit:
-
#table(headers : Enumerable, rows : Enumerable) : Nil
Formats and prints a table based on the provided headers and rows, followed by a new line.
-
#text(messages : String | Enumerable(String)) : Nil
:inherit:
-
#title(message : String) : Nil
Formats and prints message as a title.
-
#vertical_table(headers : Enumerable, rows : Enumerable) : Nil
Sames as
#table, but vertical -
#warning(messages : String | Enumerable(String)) : Nil
:inherit:
Instance methods inherited from class Athena::Console::Style::Output
create_progress_bar(max : Int32 | Nil = nil) : ACON::Helper::ProgressBar
create_progress_bar,
decorated=(decorated : Bool) : Nil
decorated=,
decorated? : Bool
decorated?,
formatter : ACON::Formatter::Interface
formatter,
formatter=(formatter : ACON::Formatter::Interface) : Nil
formatter=,
new_line(count : Int32 = 1) : Nil
new_line,
print(message, verbosity : ACON::Output::Verbosity = :normal, output_type : ACON::Output::Type = :normal) : Nil
print,
puts(message, verbosity : ACON::Output::Verbosity = :normal, output_type : ACON::Output::Type = :normal) : Nil
puts,
verbosity : ACON::Output::Verbosity
verbosity,
verbosity=(verbosity : ACON::Output::Verbosity) : Nil
verbosity=
Constructor methods inherited from class Athena::Console::Style::Output
new(output : ACON::Output::Interface)
new
Instance methods inherited from module Athena::Console::Output::Interface
decorated=(decorated : Bool) : Nil
decorated=,
decorated? : Bool
decorated?,
formatter : ACON::Formatter::Interface
formatter,
formatter=(formatter : ACON::Formatter::Interface) : Nil
formatter=,
print(message : String | Enumerable(String), verbosity : ACON::Output::Verbosity = :normal, output_type : ACON::Output::Type = :normal) : Nil
print,
puts(message : String | Enumerable(String), verbosity : ACON::Output::Verbosity = :normal, output_type : ACON::Output::Type = :normal) : Nil
puts,
verbosity : ACON::Output::Verbosity
verbosity,
verbosity=(verbosity : ACON::Output::Verbosity) : Nil
verbosity=
Instance methods inherited from module Athena::Console::Style::Interface
ask(question : String, default : _)
ask,
ask_hidden(question : String)
ask_hidden,
caution(messages : String | Enumerable(String)) : Nil
caution,
choice(question : String, choices : Indexable | Hash, default = nil)
choice,
comment(messages : String | Enumerable(String)) : Nil
comment,
confirm(question : String, default : Bool = true) : Bool
confirm,
error(messages : String | Enumerable(String)) : Nil
error,
info(messages : String | Enumerable(String)) : Nil
info,
listing(elements : Enumerable) : Nil
listing,
new_line(count : Int32 = 1) : Nil
new_line,
note(messages : String | Enumerable(String)) : Nil
note,
progress_advance(by step : Int32 = 1) : Nil
progress_advance,
progress_finish : Nil
progress_finish,
progress_start(max : Int32 | Nil = nil) : Nil
progress_start,
section(message : String) : Nil
section,
success(messages : String | Enumerable(String)) : Nil
success,
table(headers : Enumerable, rows : Enumerable) : Nil
table,
text(messages : String | Enumerable(String)) : Nil
text,
title(message : String) : Nil
title,
warning(messages : String | Enumerable(String)) : Nil
warning
Constructor Detail
Instance Method Detail
Helper method for outputting blocks of messages that powers the #caution, #success, #note, etc. methods.
It includes various optional parameters that can be used to print customized blocks.
If type is provided, its value will be printed within []. E.g. [TYPE].
If style is provided, each of the messages will be printed in that style.
prefix represents what each of the messages should be prefixed with.
If padding is true, empty lines will be added before/after the block.
If escape is true, each of the messages will be escaped via ACON::Formatter::Output.escape.
:inherit:
!
! [CAUTION] Some Message
!
White text on a 3 line red background block with an empty line above/below the block.
Helper method for asking ACON::Question::Choice questions.
:inherit:
// Some Message
White text with one empty line above/below the message(s).
Helper method for asking ACON::Question::Confirmation questions.
Creates and returns an ACON::Helper::ProgressBar, optionally with the provided max amount of steps.
Creates and returns an Athena styled ACON::Helper::Table instance.
Formats a list of key/value pairs horizontally.
TODO Mappable when/if https://github.com/crystal-lang/crystal/issues/10886 is implemented.
:inherit:
[ERROR] Some Message
White text on a 3 line red background block with an empty line above/below the block.
Sames as #table, but horizontal
:inherit:
[INFO] Some Message
Green text with two empty lines above/below the message(s).
Formats and prints a bulleted list containing the provided elements.
* Item 1
* Item 2
* Item 3
White text with one empty line above/below the list.
:inherit:
* Item 1
* Item 2
* Item 3
White text with one empty line above/below the list.
:inherit:
! [NOTE] Some Message
Green text with one empty line above/below the message(s).
:inherit:
Advances the internal ACON::Helper::ProgressBar by the provided amount of steps.
Starts an internal ACON::Helper::ProgressBar, optionally with the provided max amount of steps.
:inherit:
Creates a section header with the provided message.
Some Message
------------
Orange text with one empty line above/below the section.
:inherit:
[OK] Some Message
Black text on a 3 line green background block with an empty line above/below the block.
Formats and prints a table based on the provided headers and rows, followed by a new line.
----- -------
Foo Bar
----- -------
Biz Baz
12 false
----- -------
:inherit:
Same as #puts but indented one space and an empty line above the message(s).
Formats and prints message as a title.
Some Message
============
Orange text with one empty line above/below the title.
:inherit:
[WARNING] Some Message
Black text on a 3 line orange background block with an empty line above/below the block.