generated from athena-framework/component-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
output.cr
69 lines (54 loc) · 2.04 KB
/
output.cr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
require "./interface"
# Base implementation of `ACON::Style::Interface` and `ACON::Output::Interface` that provides logic common to all styles.
abstract class Athena::Console::Style::Output
include Athena::Console::Style::Interface
include Athena::Console::Output::Interface
@output : ACON::Output::Interface
def initialize(@output : ACON::Output::Interface); end
# See `ACON::Output::Interface#decorated?`.
def decorated? : Bool
@output.decorated?
end
# See `ACON::Output::Interface#decorated=`.
def decorated=(decorated : Bool) : Nil
@output.decorated = decorated
end
# See `ACON::Output::Interface#formatter`.
def formatter : ACON::Formatter::Interface
@output.formatter
end
# See `ACON::Output::Interface#formatter=`.
def formatter=(formatter : ACON::Formatter::Interface) : Nil
@output.formatter = formatter
end
# :inherit:
def new_line(count : Int32 = 1) : Nil
@output.print EOL * count
end
# Creates and returns an `ACON::Helper::ProgressBar`, optionally with the provided *max* amount of steps.
def create_progress_bar(max : Int32? = nil) : ACON::Helper::ProgressBar
ACON::Helper::ProgressBar.new @output, max
end
# See `ACON::Output::Interface#puts`.
def puts(message, verbosity : ACON::Output::Verbosity = :normal, output_type : ACON::Output::Type = :normal) : Nil
@output.puts message, verbosity, output_type
end
# See `ACON::Output::Interface#print`.
def print(message, verbosity : ACON::Output::Verbosity = :normal, output_type : ACON::Output::Type = :normal) : Nil
@output.print message, verbosity, output_type
end
# See `ACON::Output::Interface#verbosity`.
def verbosity : ACON::Output::Verbosity
@output.verbosity
end
# See `ACON::Output::Interface#verbosity=`.
def verbosity=(verbosity : ACON::Output::Verbosity) : Nil
@output.verbosity = verbosity
end
protected def error_output : ACON::Output::Interface
unless (output = @output).is_a? ACON::Output::ConsoleOutputInterface
return @output
end
output.error_output
end
end