Skip to content

class Athena::Console::Style::Athena
inherits Athena::Console::Style::Output #

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

Constructors#

Methods#

#ask(question : String, default : _) #

Helper method for asking ACON::Question questions.

View source

#ask(question : ACON::Question::Base) #

:inherit:

View source

#ask_hidden(question : String) #

Helper method for asking hidden ACON::Question questions.

View source

#block(messages : String | Enumerable(String), type : String? = nil, style : String? = nil, prefix : String = " ", padding : Bool = false, escape : Bool = true) : Nil #

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.

View source

#caution(messages : String | Enumerable(String)) : Nil #

Formats and prints the provided messages within a caution block.

!
! [CAUTION] Some Message
!

White text on a 3 line red background block with an empty line above/below the block.

View source

#choice(question : String, choices : Indexable | Hash, default = nil) #

Helper method for asking ACON::Question::Choice questions.

View source

#comment(messages : String | Enumerable(String)) : Nil #

Formats and prints the provided messages within a comment block.

// Some Message

White text with one empty line above/below the message(s).

View source

#confirm(question : String, default : Bool = true) : Bool #

Helper method for asking ACON::Question::Confirmation questions.

View source

#error(messages : String | Enumerable(String)) : Nil #

Formats and prints the provided messages within a error block.

[ERROR] Some Message

White text on a 3 line red background block with an empty line above/below the block.

View source

#error_style #

Returns a new instance of self that outputs to the error output.

View source

#info(messages : String | Enumerable(String)) : Nil #

Formats and prints the provided messages within a info block.

[INFO] Some Message

Green text with two empty lines above/below the message(s).

View source

#listing(elements : Enumerable) : Nil #

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.

View source

#listing(*elements : String) : Nil #

:inherit:

* Item 1
* Item 2
* Item 3

White text with one empty line above/below the list.

View source

#new_line(count : Int32 = 1) : Nil #

:inherit:

View source

#note(messages : String | Enumerable(String)) : Nil #

Formats and prints the provided messages within a note block.

! [NOTE] Some Message

Green text with one empty line above/below the message(s).

View source

#print(messages : String | Enumerable(String), verbosity : ACON::Output::Verbosity = :normal, output_type : ACON::Output::Type = :normal) : Nil #

Outputs the provided message. The verbosity and/or output_type parameters can be used to control when and how the message is printed.

View source

#puts(messages : String | Enumerable(String), verbosity : ACON::Output::Verbosity = :normal, output_type : ACON::Output::Type = :normal) : Nil #

Outputs the provided message followed by a new line. The verbosity and/or output_type parameters can be used to control when and how the message is printed.

View source

#section(message : String) : Nil #

Creates a section header with the provided message.

Some Message
------------

Orange text with one empty line above/below the section.

View source

#success(messages : String | Enumerable(String)) : Nil #

Formats and prints the provided messages within a success block.

 [OK] Some Message

Black text on a 3 line green background block with an empty line above/below the block.

View source

#text(messages : String | Enumerable(String)) : Nil #

Formats and prints the provided messages as text.

Same as #puts but indented one space and an empty line above the message(s).

View source

#title(message : String) : Nil #

Formats and prints message as a title.

Some Message
============

Orange text with one empty line above/below the title.

View source

#warning(messages : String | Enumerable(String)) : Nil #

Formats and prints the provided messages within a warning block.

 [WARNING] Some Message

Black text on a 3 line orange background block with an empty line above/below the block.

View source