class Athena::Console::Output::Section
inherits Athena::Console::Output::IO
#
A ACON::Output::ConsoleOutput
can be divided into multiple sections that can be written to and cleared independently of one another.
Output sections can be used for advanced console outputs, such as displaying multiple progress bars which are updated independently, or appending additional rows to tables.
protected def execute(input : ACON::Input::Interface, output : ACON::Output::Interface) : ACON::Command::Status
raise ArgumentError.new "This command may only be used with `ACON::Output::ConsoleOutputInterface`." unless output.is_a? ACON::Output::ConsoleOutputInterface
section1 = output.section
section2 = output.section
section1.puts "Hello"
section2.puts "World!"
# Output contains "Hello\nWorld!\n"
sleep 1.second
# Replace "Hello" with "Goodbye!"
section1.overwrite "Goodbye!"
# Output now contains "Goodbye\nWorld!\n"
sleep 1.second
# Clear "World!"
section2.clear
# Output now contains "Goodbye!\n"
sleep 1.second
# Delete the last 2 lines of the first section
section1.clear 2
# Output is now empty
ACON::Command::Status::SUCCESS
end
Constructors#
.new(io : ::IO, sections : Array(self), verbosity : ACON::Output::Verbosity, decorated : Bool, formatter : ACON::Formatter::Interface)
#
Methods#
#clear(lines : Int32 | Nil = nil) : Nil
#
Clears at most lines from self
.
If lines is nil
, all of self
is cleared.
#content : String
#
Returns the full content string contained within self
.
#max_height=(max_height : Int32 | Nil) : Nil
#
#overwrite(message : String | Enumerable(String)) : Nil
#
Overrides the current content of self
with the provided message.
#overwrite(*messages : String) : Nil
#
Overrides the current content of self
with the provided messages.