cli-ui 2.3.1 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cli/ui/ansi.rb +23 -27
- data/lib/cli/ui/color.rb +8 -13
- data/lib/cli/ui/formatter.rb +24 -23
- data/lib/cli/ui/frame/frame_stack.rb +9 -21
- data/lib/cli/ui/frame/frame_style/box.rb +11 -10
- data/lib/cli/ui/frame/frame_style/bracket.rb +11 -10
- data/lib/cli/ui/frame/frame_style.rb +31 -22
- data/lib/cli/ui/frame.rb +12 -43
- data/lib/cli/ui/glyph.rb +8 -14
- data/lib/cli/ui/os.rb +9 -10
- data/lib/cli/ui/printer.rb +1 -15
- data/lib/cli/ui/progress.rb +20 -23
- data/lib/cli/ui/progress_reporter.rb +209 -0
- data/lib/cli/ui/prompt/interactive_options.rb +85 -53
- data/lib/cli/ui/prompt/options_handler.rb +4 -6
- data/lib/cli/ui/prompt.rb +22 -45
- data/lib/cli/ui/spinner/async.rb +3 -7
- data/lib/cli/ui/spinner/spin_group.rb +205 -135
- data/lib/cli/ui/spinner.rb +3 -16
- data/lib/cli/ui/stdout_router.rb +38 -55
- data/lib/cli/ui/table.rb +3 -7
- data/lib/cli/ui/terminal.rb +4 -8
- data/lib/cli/ui/truncater.rb +5 -6
- data/lib/cli/ui/version.rb +1 -1
- data/lib/cli/ui/widgets/base.rb +13 -14
- data/lib/cli/ui/widgets/status.rb +10 -10
- data/lib/cli/ui/widgets.rb +7 -15
- data/lib/cli/ui/work_queue.rb +23 -27
- data/lib/cli/ui/wrap.rb +3 -5
- data/lib/cli/ui.rb +42 -97
- metadata +4 -7
- data/lib/cli/ui/sorbet_runtime_stub.rb +0 -169
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff323415fd623b745426ec805bffd7f768556bf90036b16e5a59159fe288e04a
|
4
|
+
data.tar.gz: 1af5e6bbffc30826a8180078e1c0bc66d0de832396d5f1efb9487535693d6bee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db97a7a85a062661707953c1049abc0fb5289846260032edadf81beac799b2d81f22fba1289f89dc22a2e8aa99ccfbeffb1dfb14d348cc74b4c4ef85cb6d5031
|
7
|
+
data.tar.gz: 013f02c7461aad82f5242a051a1fbe0f95687338109e40fcf38c4525b37f4c522fa8714a37d417bff98f0718bec5ea607598183a38154265240974e638c300bc
|
data/lib/cli/ui/ansi.rb
CHANGED
@@ -6,21 +6,17 @@ require 'cli/ui'
|
|
6
6
|
module CLI
|
7
7
|
module UI
|
8
8
|
module ANSI
|
9
|
-
extend T::Sig
|
10
|
-
|
11
9
|
ESC = "\x1b"
|
12
10
|
|
13
11
|
class << self
|
14
|
-
extend T::Sig
|
15
|
-
|
16
12
|
# ANSI escape sequences (like \x1b[31m) have zero width.
|
17
13
|
# when calculating the padding width, we must exclude them.
|
18
14
|
# This also implements a basic version of utf8 character width calculation like
|
19
15
|
# we could get for real from something like utf8proc.
|
20
16
|
#
|
21
|
-
|
17
|
+
#: (String str) -> Integer
|
22
18
|
def printing_width(str)
|
23
|
-
zwj =
|
19
|
+
zwj = false #: bool
|
24
20
|
strip_codes(str).codepoints.reduce(0) do |acc, cp|
|
25
21
|
if zwj
|
26
22
|
zwj = false
|
@@ -44,7 +40,7 @@ module CLI
|
|
44
40
|
#
|
45
41
|
# - +str+ - The string from which to strip codes
|
46
42
|
#
|
47
|
-
|
43
|
+
#: (String str) -> String
|
48
44
|
def strip_codes(str)
|
49
45
|
str.gsub(/\x1b\[[\d;]+[A-Za-z]|\x1b\][\d;]+.*?\x1b\\|\r/, '')
|
50
46
|
end
|
@@ -56,13 +52,13 @@ module CLI
|
|
56
52
|
# - +args+ - Argument to pass to the ANSI control sequence
|
57
53
|
# - +cmd+ - ANSI control sequence Command
|
58
54
|
#
|
59
|
-
|
55
|
+
#: (String args, String cmd) -> String
|
60
56
|
def control(args, cmd)
|
61
57
|
ESC + '[' + args + cmd
|
62
58
|
end
|
63
59
|
|
64
60
|
# https://en.wikipedia.org/wiki/ANSI_escape_code#graphics
|
65
|
-
|
61
|
+
#: (String params) -> String
|
66
62
|
def sgr(params)
|
67
63
|
control(params, 'm')
|
68
64
|
end
|
@@ -75,7 +71,7 @@ module CLI
|
|
75
71
|
#
|
76
72
|
# * +n+ - number of lines by which to move the cursor up
|
77
73
|
#
|
78
|
-
|
74
|
+
#: (?Integer n) -> String
|
79
75
|
def cursor_up(n = 1)
|
80
76
|
return '' if n.zero?
|
81
77
|
|
@@ -88,7 +84,7 @@ module CLI
|
|
88
84
|
#
|
89
85
|
# * +n+ - number of lines by which to move the cursor down
|
90
86
|
#
|
91
|
-
|
87
|
+
#: (?Integer n) -> String
|
92
88
|
def cursor_down(n = 1)
|
93
89
|
return '' if n.zero?
|
94
90
|
|
@@ -101,7 +97,7 @@ module CLI
|
|
101
97
|
#
|
102
98
|
# * +n+ - number of columns by which to move the cursor forward
|
103
99
|
#
|
104
|
-
|
100
|
+
#: (?Integer n) -> String
|
105
101
|
def cursor_forward(n = 1)
|
106
102
|
return '' if n.zero?
|
107
103
|
|
@@ -114,7 +110,7 @@ module CLI
|
|
114
110
|
#
|
115
111
|
# * +n+ - number of columns by which to move the cursor back
|
116
112
|
#
|
117
|
-
|
113
|
+
#: (?Integer n) -> String
|
118
114
|
def cursor_back(n = 1)
|
119
115
|
return '' if n.zero?
|
120
116
|
|
@@ -127,66 +123,66 @@ module CLI
|
|
127
123
|
#
|
128
124
|
# * +n+ - The column to move to
|
129
125
|
#
|
130
|
-
|
126
|
+
#: (?Integer n) -> String
|
131
127
|
def cursor_horizontal_absolute(n = 1)
|
132
128
|
cmd = control(n.to_s, 'G')
|
133
129
|
cmd += cursor_back if CLI::UI::OS.current.shift_cursor_back_on_horizontal_absolute?
|
134
130
|
cmd
|
135
131
|
end
|
136
132
|
|
137
|
-
|
133
|
+
#: -> String
|
138
134
|
def enter_alternate_screen
|
139
135
|
control('?1049', 'h')
|
140
136
|
end
|
141
137
|
|
142
|
-
|
138
|
+
#: -> String
|
143
139
|
def exit_alternate_screen
|
144
140
|
control('?1049', 'l')
|
145
141
|
end
|
146
142
|
|
147
|
-
|
143
|
+
#: -> Regexp
|
148
144
|
def match_alternate_screen
|
149
145
|
/#{Regexp.escape(control("?1049", ""))}[hl]/
|
150
146
|
end
|
151
147
|
|
152
148
|
# Show the cursor
|
153
149
|
#
|
154
|
-
|
150
|
+
#: -> String
|
155
151
|
def show_cursor
|
156
152
|
control('', '?25h')
|
157
153
|
end
|
158
154
|
|
159
155
|
# Hide the cursor
|
160
156
|
#
|
161
|
-
|
157
|
+
#: -> String
|
162
158
|
def hide_cursor
|
163
159
|
control('', '?25l')
|
164
160
|
end
|
165
161
|
|
166
162
|
# Save the cursor position
|
167
163
|
#
|
168
|
-
|
164
|
+
#: -> String
|
169
165
|
def cursor_save
|
170
166
|
control('', 's')
|
171
167
|
end
|
172
168
|
|
173
169
|
# Restore the saved cursor position
|
174
170
|
#
|
175
|
-
|
171
|
+
#: -> String
|
176
172
|
def cursor_restore
|
177
173
|
control('', 'u')
|
178
174
|
end
|
179
175
|
|
180
176
|
# Move to the next line
|
181
177
|
#
|
182
|
-
|
178
|
+
#: -> String
|
183
179
|
def next_line
|
184
180
|
cursor_down + cursor_horizontal_absolute
|
185
181
|
end
|
186
182
|
|
187
183
|
# Move to the previous line
|
188
184
|
#
|
189
|
-
|
185
|
+
#: -> String
|
190
186
|
def previous_line
|
191
187
|
previous_lines(1)
|
192
188
|
end
|
@@ -197,22 +193,22 @@ module CLI
|
|
197
193
|
#
|
198
194
|
# * +n+ - number of lines by which to move the cursor up
|
199
195
|
#
|
200
|
-
|
196
|
+
#: (?Integer n) -> String
|
201
197
|
def previous_lines(n = 1)
|
202
198
|
cursor_up(n) + cursor_horizontal_absolute
|
203
199
|
end
|
204
200
|
|
205
|
-
|
201
|
+
#: -> String
|
206
202
|
def clear_to_end_of_line
|
207
203
|
control('', 'K')
|
208
204
|
end
|
209
205
|
|
210
|
-
|
206
|
+
#: -> String
|
211
207
|
def insert_line
|
212
208
|
insert_lines(1)
|
213
209
|
end
|
214
210
|
|
215
|
-
|
211
|
+
#: (?Integer n) -> String
|
216
212
|
def insert_lines(n = 1)
|
217
213
|
control(n.to_s, 'L')
|
218
214
|
end
|
data/lib/cli/ui/color.rb
CHANGED
@@ -6,12 +6,10 @@ require 'cli/ui'
|
|
6
6
|
module CLI
|
7
7
|
module UI
|
8
8
|
class Color
|
9
|
-
|
10
|
-
|
11
|
-
sig { returns(String) }
|
9
|
+
#: String
|
12
10
|
attr_reader :sgr, :code
|
13
11
|
|
14
|
-
|
12
|
+
#: Symbol
|
15
13
|
attr_reader :name
|
16
14
|
|
17
15
|
# Creates a new color mapping
|
@@ -23,7 +21,7 @@ module CLI
|
|
23
21
|
# * +sgr+ - The color signature
|
24
22
|
# * +name+ - The name of the color
|
25
23
|
#
|
26
|
-
|
24
|
+
#: (String sgr, Symbol name) -> void
|
27
25
|
def initialize(sgr, name)
|
28
26
|
@sgr = sgr
|
29
27
|
@code = CLI::UI::ANSI.sgr(sgr)
|
@@ -56,18 +54,17 @@ module CLI
|
|
56
54
|
reset: RESET,
|
57
55
|
bold: BOLD,
|
58
56
|
gray: GRAY,
|
57
|
+
orange: ORANGE,
|
59
58
|
}.freeze
|
60
59
|
|
61
60
|
class InvalidColorName < ArgumentError
|
62
|
-
|
63
|
-
|
64
|
-
sig { params(name: Symbol).void }
|
61
|
+
#: (Symbol name) -> void
|
65
62
|
def initialize(name)
|
66
63
|
super
|
67
64
|
@name = name
|
68
65
|
end
|
69
66
|
|
70
|
-
|
67
|
+
#: -> String
|
71
68
|
def message
|
72
69
|
keys = Color.available.map(&:inspect).join(',')
|
73
70
|
"invalid color: #{@name.inspect} " \
|
@@ -76,8 +73,6 @@ module CLI
|
|
76
73
|
end
|
77
74
|
|
78
75
|
class << self
|
79
|
-
extend T::Sig
|
80
|
-
|
81
76
|
# Looks up a color code by name
|
82
77
|
#
|
83
78
|
# ==== Raises
|
@@ -87,7 +82,7 @@ module CLI
|
|
87
82
|
# ==== Returns
|
88
83
|
# Returns a color code
|
89
84
|
#
|
90
|
-
|
85
|
+
#: ((Symbol | String) name) -> Color
|
91
86
|
def lookup(name)
|
92
87
|
MAP.fetch(name.to_sym)
|
93
88
|
rescue KeyError
|
@@ -96,7 +91,7 @@ module CLI
|
|
96
91
|
|
97
92
|
# All available colors by name
|
98
93
|
#
|
99
|
-
|
94
|
+
#: -> Array[Symbol]
|
100
95
|
def available
|
101
96
|
MAP.keys
|
102
97
|
end
|
data/lib/cli/ui/formatter.rb
CHANGED
@@ -7,8 +7,6 @@ require('strscan')
|
|
7
7
|
module CLI
|
8
8
|
module UI
|
9
9
|
class Formatter
|
10
|
-
extend T::Sig
|
11
|
-
|
12
10
|
# Available mappings of formattings
|
13
11
|
# To use any of them, you can use {{<key>:<string>}}
|
14
12
|
# There are presentational (colours and formatters)
|
@@ -24,6 +22,7 @@ module CLI
|
|
24
22
|
'magenta' => '35',
|
25
23
|
'cyan' => '36',
|
26
24
|
'gray' => '38;5;244',
|
25
|
+
'orange' => '38;5;214',
|
27
26
|
'white' => '97',
|
28
27
|
'bold' => '1',
|
29
28
|
'italic' => '3',
|
@@ -58,18 +57,16 @@ module CLI
|
|
58
57
|
|
59
58
|
LITERAL_BRACES = Class.new
|
60
59
|
|
61
|
-
|
60
|
+
#: type stack = Array[String | LITERAL_BRACES]
|
62
61
|
|
63
62
|
class FormatError < StandardError
|
64
|
-
|
65
|
-
|
66
|
-
sig { returns(String) }
|
63
|
+
#: String
|
67
64
|
attr_accessor :input
|
68
65
|
|
69
|
-
|
66
|
+
#: Integer
|
70
67
|
attr_accessor :index
|
71
68
|
|
72
|
-
|
69
|
+
#: (String message, String input, Integer index) -> void
|
73
70
|
def initialize(message, input, index)
|
74
71
|
super(message)
|
75
72
|
@input = input
|
@@ -83,10 +80,10 @@ module CLI
|
|
83
80
|
#
|
84
81
|
# * +text+ - the text to format
|
85
82
|
#
|
86
|
-
|
83
|
+
#: (String text) -> void
|
87
84
|
def initialize(text)
|
88
85
|
@text = text
|
89
|
-
@nodes =
|
86
|
+
@nodes = [] #: Array[[String, stack]]
|
90
87
|
end
|
91
88
|
|
92
89
|
# Format the text using a map.
|
@@ -99,11 +96,11 @@ module CLI
|
|
99
96
|
#
|
100
97
|
# * +:enable_color+ - enable color output? Default is true unless output is redirected
|
101
98
|
#
|
102
|
-
|
99
|
+
#: (?Hash[String, String] sgr_map, ?enable_color: bool) -> String
|
103
100
|
def format(sgr_map = SGR_MAP, enable_color: CLI::UI.enable_color?)
|
104
101
|
@nodes.replace([])
|
105
102
|
stack = parse_body(StringScanner.new(@text))
|
106
|
-
prev_fmt =
|
103
|
+
prev_fmt = nil #: stack?
|
107
104
|
content = @nodes.each_with_object(+'') do |(text, fmt), str|
|
108
105
|
if prev_fmt != fmt && enable_color
|
109
106
|
text = apply_format(text, fmt, sgr_map)
|
@@ -117,7 +114,8 @@ module CLI
|
|
117
114
|
return content unless enable_color
|
118
115
|
return content if stack == prev_fmt
|
119
116
|
|
120
|
-
|
117
|
+
last_node = @nodes.last #: as !nil
|
118
|
+
unless stack.empty? && (@nodes.empty? || last_node[1].empty?)
|
121
119
|
content << apply_format('', stack, sgr_map)
|
122
120
|
end
|
123
121
|
content
|
@@ -125,7 +123,7 @@ module CLI
|
|
125
123
|
|
126
124
|
private
|
127
125
|
|
128
|
-
|
126
|
+
#: (String text, stack fmt, Hash[String, String] sgr_map) -> String
|
129
127
|
def apply_format(text, fmt, sgr_map)
|
130
128
|
sgr = fmt.each_with_object(+'0') do |name, str|
|
131
129
|
next if name.is_a?(LITERAL_BRACES)
|
@@ -143,10 +141,10 @@ module CLI
|
|
143
141
|
CLI::UI::ANSI.sgr(sgr) + text
|
144
142
|
end
|
145
143
|
|
146
|
-
|
144
|
+
#: (StringScanner sc, stack stack) -> stack
|
147
145
|
def parse_expr(sc, stack)
|
148
146
|
if (match = sc.scan(SCAN_GLYPH))
|
149
|
-
glyph_handle =
|
147
|
+
glyph_handle = match[0] #: as !nil
|
150
148
|
begin
|
151
149
|
glyph = Glyph.lookup(glyph_handle)
|
152
150
|
emit(glyph.char, [glyph.color.name.to_s])
|
@@ -159,11 +157,12 @@ module CLI
|
|
159
157
|
)
|
160
158
|
end
|
161
159
|
elsif (match = sc.scan(SCAN_WIDGET))
|
162
|
-
match_data =
|
163
|
-
widget_handle =
|
160
|
+
match_data = SCAN_WIDGET.match(match) #: as !nil # Regexp.last_match doesn't work here
|
161
|
+
widget_handle = match_data['handle'] #: as !nil
|
164
162
|
begin
|
165
163
|
widget = Widgets.lookup(widget_handle)
|
166
|
-
|
164
|
+
args = match_data['args'] #: as !nil
|
165
|
+
emit(widget.call(args), stack)
|
167
166
|
rescue Widgets::InvalidWidgetHandle
|
168
167
|
index = sc.pos - 2 # rewind past '}}'
|
169
168
|
raise(FormatError.new(
|
@@ -187,14 +186,16 @@ module CLI
|
|
187
186
|
stack
|
188
187
|
end
|
189
188
|
|
190
|
-
|
189
|
+
#: (StringScanner sc, ?stack stack) -> stack
|
191
190
|
def parse_body(sc, stack = [])
|
192
191
|
match = sc.scan(SCAN_BODY)
|
193
192
|
if match&.end_with?(BEGIN_EXPR)
|
194
|
-
|
193
|
+
text = match[DISCARD_BRACES] #: as !nil
|
194
|
+
emit(text, stack)
|
195
195
|
parse_expr(sc, stack)
|
196
196
|
elsif match&.end_with?(END_EXPR)
|
197
|
-
|
197
|
+
text = match[DISCARD_BRACES] #: as !nil
|
198
|
+
emit(text, stack)
|
198
199
|
if stack.pop.is_a?(LITERAL_BRACES)
|
199
200
|
emit('}}', stack)
|
200
201
|
end
|
@@ -207,7 +208,7 @@ module CLI
|
|
207
208
|
stack
|
208
209
|
end
|
209
210
|
|
210
|
-
|
211
|
+
#: (String text, stack stack) -> void
|
211
212
|
def emit(text, stack)
|
212
213
|
return if text.empty?
|
213
214
|
|
@@ -6,18 +6,13 @@ module CLI
|
|
6
6
|
module Frame
|
7
7
|
module FrameStack
|
8
8
|
class StackItem
|
9
|
-
|
10
|
-
|
11
|
-
sig { returns(CLI::UI::Color) }
|
9
|
+
#: CLI::UI::Color
|
12
10
|
attr_reader :color
|
13
11
|
|
14
|
-
|
12
|
+
#: CLI::UI::Frame::FrameStyle
|
15
13
|
attr_reader :frame_style
|
16
14
|
|
17
|
-
|
18
|
-
params(color_name: CLI::UI::Colorable, style_name: FrameStylable)
|
19
|
-
.void
|
20
|
-
end
|
15
|
+
#: (CLI::UI::colorable color_name, frame_stylable style_name) -> void
|
21
16
|
def initialize(color_name, style_name)
|
22
17
|
@color = CLI::UI.resolve_color(color_name)
|
23
18
|
@frame_style = CLI::UI.resolve_style(style_name)
|
@@ -25,10 +20,8 @@ module CLI
|
|
25
20
|
end
|
26
21
|
|
27
22
|
class << self
|
28
|
-
extend T::Sig
|
29
|
-
|
30
23
|
# Fetch all items off the frame stack
|
31
|
-
|
24
|
+
#: -> Array[StackItem]
|
32
25
|
def items
|
33
26
|
Thread.current[:cliui_frame_stack] ||= []
|
34
27
|
end
|
@@ -51,24 +44,19 @@ module CLI
|
|
51
44
|
# If both an item and a color/style pair are given, raises an +ArgumentError+
|
52
45
|
# If the given item is not a +StackItem+, raises an +ArgumentError+
|
53
46
|
#
|
54
|
-
|
55
|
-
params(
|
56
|
-
item: T.nilable(StackItem),
|
57
|
-
color: T.nilable(CLI::UI::Color),
|
58
|
-
style: T.nilable(CLI::UI::Frame::FrameStyle),
|
59
|
-
)
|
60
|
-
.void
|
61
|
-
end
|
47
|
+
#: (?StackItem? item, ?color: CLI::UI::Color?, ?style: CLI::UI::Frame::FrameStyle?) -> void
|
62
48
|
def push(item = nil, color: nil, style: nil)
|
63
49
|
if color.nil? != style.nil? || item.nil? == color.nil?
|
64
50
|
raise ArgumentError, 'Must give one of item or color: and style:'
|
65
51
|
end
|
66
52
|
|
67
|
-
|
53
|
+
c = color #: as !nil
|
54
|
+
s = style #: as !nil
|
55
|
+
items.push(item || StackItem.new(c, s))
|
68
56
|
end
|
69
57
|
|
70
58
|
# Removes and returns the last stack item off the stack
|
71
|
-
|
59
|
+
#: -> StackItem?
|
72
60
|
def pop
|
73
61
|
items.pop
|
74
62
|
end
|
@@ -15,14 +15,14 @@ module CLI
|
|
15
15
|
BOTTOM_LEFT = '┗'
|
16
16
|
|
17
17
|
class << self
|
18
|
-
|
19
|
-
|
20
|
-
sig { override.returns(Symbol) }
|
18
|
+
# @override
|
19
|
+
#: -> Symbol
|
21
20
|
def style_name
|
22
21
|
:box
|
23
22
|
end
|
24
23
|
|
25
|
-
|
24
|
+
# @override
|
25
|
+
#: -> String
|
26
26
|
def prefix
|
27
27
|
VERTICAL
|
28
28
|
end
|
@@ -41,7 +41,8 @@ module CLI
|
|
41
41
|
#
|
42
42
|
# ┏━━ Open ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
43
43
|
#
|
44
|
-
|
44
|
+
# @override
|
45
|
+
#: (String text, color: CLI::UI::Color) -> String
|
45
46
|
def start(text, color:)
|
46
47
|
edge(text, color: color, first: TOP_LEFT)
|
47
48
|
end
|
@@ -60,7 +61,8 @@ module CLI
|
|
60
61
|
#
|
61
62
|
# ┣━━ Divider ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
62
63
|
#
|
63
|
-
|
64
|
+
# @override
|
65
|
+
#: (String text, color: CLI::UI::Color) -> String
|
64
66
|
def divider(text, color:)
|
65
67
|
edge(text, color: color, first: DIVIDER)
|
66
68
|
end
|
@@ -80,16 +82,15 @@ module CLI
|
|
80
82
|
#
|
81
83
|
# ┗━━ Close ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
82
84
|
#
|
83
|
-
|
85
|
+
# @override
|
86
|
+
#: (String text, color: CLI::UI::Color, ?right_text: String?) -> String
|
84
87
|
def close(text, color:, right_text: nil)
|
85
88
|
edge(text, color: color, right_text: right_text, first: BOTTOM_LEFT)
|
86
89
|
end
|
87
90
|
|
88
91
|
private
|
89
92
|
|
90
|
-
|
91
|
-
params(text: String, color: CLI::UI::Color, first: String, right_text: T.nilable(String)).returns(String)
|
92
|
-
end
|
93
|
+
#: (String text, color: CLI::UI::Color, first: String, ?right_text: String?) -> String
|
93
94
|
def edge(text, color:, first:, right_text: nil)
|
94
95
|
color = CLI::UI.resolve_color(color)
|
95
96
|
|
@@ -15,14 +15,14 @@ module CLI
|
|
15
15
|
BOTTOM_LEFT = '┗'
|
16
16
|
|
17
17
|
class << self
|
18
|
-
|
19
|
-
|
20
|
-
sig { override.returns(Symbol) }
|
18
|
+
# @override
|
19
|
+
#: -> Symbol
|
21
20
|
def style_name
|
22
21
|
:bracket
|
23
22
|
end
|
24
23
|
|
25
|
-
|
24
|
+
# @override
|
25
|
+
#: -> String
|
26
26
|
def prefix
|
27
27
|
VERTICAL
|
28
28
|
end
|
@@ -41,7 +41,8 @@ module CLI
|
|
41
41
|
#
|
42
42
|
# ┏━━ Open
|
43
43
|
#
|
44
|
-
|
44
|
+
# @override
|
45
|
+
#: (String text, color: CLI::UI::Color) -> String
|
45
46
|
def start(text, color:)
|
46
47
|
edge(text, color: color, first: TOP_LEFT)
|
47
48
|
end
|
@@ -60,7 +61,8 @@ module CLI
|
|
60
61
|
#
|
61
62
|
# ┣━━ Divider
|
62
63
|
#
|
63
|
-
|
64
|
+
# @override
|
65
|
+
#: (String text, color: CLI::UI::Color) -> String
|
64
66
|
def divider(text, color:)
|
65
67
|
edge(text, color: color, first: DIVIDER)
|
66
68
|
end
|
@@ -80,16 +82,15 @@ module CLI
|
|
80
82
|
#
|
81
83
|
# ┗━━ Close
|
82
84
|
#
|
83
|
-
|
85
|
+
# @override
|
86
|
+
#: (String text, color: CLI::UI::Color, ?right_text: String?) -> String
|
84
87
|
def close(text, color:, right_text: nil)
|
85
88
|
edge(text, color: color, right_text: right_text, first: BOTTOM_LEFT)
|
86
89
|
end
|
87
90
|
|
88
91
|
private
|
89
92
|
|
90
|
-
|
91
|
-
params(text: String, color: CLI::UI::Color, first: String, right_text: T.nilable(String)).returns(String)
|
92
|
-
end
|
93
|
+
#: (String text, color: CLI::UI::Color, first: String, ?right_text: String?) -> String
|
93
94
|
def edge(text, color:, first:, right_text: nil)
|
94
95
|
color = CLI::UI.resolve_color(color)
|
95
96
|
|