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 # Replace "Hello" with "Goodbye!" section1.overwrite "Goodbye!" # Output now contains "Goodbye\nWorld!\n" sleep 1 # Clear "World!" section2.clear # Output now contains "Goodbye!\n" sleep 1 # Delete the last 2 lines of the first section section1.clear 2 # Output is now empty ACON::Command::Status::SUCCESS end
.new(io : ::IO, sections : Array(self), verbosity : ACON::Output::Verbosity, decorated : Bool, formatter : ACON::Formatter::Interface)#
#clear(lines : Int32 | Nil = nil) : Nil#
Clears at most lines from
If lines is
nil, all of
self is cleared.
#overwrite(message : String | Enumerable(String)) : Nil#
Overrides the current content of
self with the provided message.