tty 0.2.1 → 0.3.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/CHANGELOG.md +12 -0
- data/README.md +45 -115
- data/lib/tty.rb +3 -31
- data/lib/tty/plugins/plugin.rb +2 -2
- data/lib/tty/terminal.rb +2 -58
- data/lib/tty/terminal/home.rb +27 -9
- data/lib/tty/version.rb +1 -1
- data/spec/tty/plugins/plugin/load_spec.rb +10 -18
- data/spec/tty/system/editor/open_spec.rb +1 -1
- data/spec/tty/terminal/home_spec.rb +18 -26
- data/spec/tty/tty_spec.rb +1 -1
- data/spec/tty/vector/new_spec.rb +1 -1
- metadata +2 -83
- data/lib/tty/shell.rb +0 -211
- data/lib/tty/shell/distance.rb +0 -49
- data/lib/tty/shell/question.rb +0 -335
- data/lib/tty/shell/question/modifier.rb +0 -93
- data/lib/tty/shell/question/validation.rb +0 -92
- data/lib/tty/shell/reader.rb +0 -110
- data/lib/tty/shell/response.rb +0 -249
- data/lib/tty/shell/response_delegation.rb +0 -55
- data/lib/tty/shell/statement.rb +0 -60
- data/lib/tty/shell/suggestion.rb +0 -126
- data/lib/tty/support/utils.rb +0 -16
- data/lib/tty/terminal/echo.rb +0 -38
- data/lib/tty/terminal/raw.rb +0 -38
- data/spec/tty/shell/ask_spec.rb +0 -77
- data/spec/tty/shell/distance/distance_spec.rb +0 -75
- data/spec/tty/shell/distance/initialize_spec.rb +0 -14
- data/spec/tty/shell/error_spec.rb +0 -30
- data/spec/tty/shell/print_table_spec.rb +0 -24
- data/spec/tty/shell/question/argument_spec.rb +0 -30
- data/spec/tty/shell/question/character_spec.rb +0 -24
- data/spec/tty/shell/question/default_spec.rb +0 -25
- data/spec/tty/shell/question/in_spec.rb +0 -23
- data/spec/tty/shell/question/initialize_spec.rb +0 -24
- data/spec/tty/shell/question/modifier/apply_to_spec.rb +0 -34
- data/spec/tty/shell/question/modifier/letter_case_spec.rb +0 -27
- data/spec/tty/shell/question/modifier/whitespace_spec.rb +0 -33
- data/spec/tty/shell/question/modify_spec.rb +0 -44
- data/spec/tty/shell/question/valid_spec.rb +0 -46
- data/spec/tty/shell/question/validate_spec.rb +0 -30
- data/spec/tty/shell/question/validation/coerce_spec.rb +0 -24
- data/spec/tty/shell/question/validation/valid_value_spec.rb +0 -28
- data/spec/tty/shell/reader/getc_spec.rb +0 -42
- data/spec/tty/shell/response/read_bool_spec.rb +0 -40
- data/spec/tty/shell/response/read_char_spec.rb +0 -16
- data/spec/tty/shell/response/read_date_spec.rb +0 -20
- data/spec/tty/shell/response/read_email_spec.rb +0 -42
- data/spec/tty/shell/response/read_multiple_spec.rb +0 -23
- data/spec/tty/shell/response/read_number_spec.rb +0 -28
- data/spec/tty/shell/response/read_range_spec.rb +0 -31
- data/spec/tty/shell/response/read_spec.rb +0 -68
- data/spec/tty/shell/response/read_string_spec.rb +0 -19
- data/spec/tty/shell/say_spec.rb +0 -67
- data/spec/tty/shell/statement/initialize_spec.rb +0 -15
- data/spec/tty/shell/suggest_spec.rb +0 -50
- data/spec/tty/shell/warn_spec.rb +0 -30
- data/spec/tty/terminal/color_spec.rb +0 -16
- data/spec/tty/terminal/echo_spec.rb +0 -21
data/lib/tty/version.rb
CHANGED
@@ -5,28 +5,20 @@ require 'spec_helper'
|
|
5
5
|
describe TTY::Plugin, '#load!' do
|
6
6
|
let(:gem) { Gem::Specification.new('tty-console', '3.1.3')}
|
7
7
|
let(:name) { 'console'}
|
8
|
-
let(:input) { StringIO.new }
|
9
|
-
let(:output) { StringIO.new }
|
10
8
|
|
11
9
|
subject(:plugin) { described_class.new(name, gem) }
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
subject.load!
|
19
|
-
expect(TTY.shell).to have_received(:error).with(/Unable to load plugin tty-console./)
|
20
|
-
end
|
11
|
+
it 'fails to load the gem' do
|
12
|
+
allow(Kernel).to receive(:require) { raise LoadError }
|
13
|
+
expect {
|
14
|
+
plugin.load!
|
15
|
+
}.to output(/Unable to load plugin tty-console./).to_stdout
|
21
16
|
end
|
22
17
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
subject.load!
|
29
|
-
expect(TTY.shell).to have_received(:error).with(/Unable to load plugin tty-console./)
|
30
|
-
end
|
18
|
+
it 'fails to require the gem' do
|
19
|
+
allow(Kernel).to receive(:require) { raise StandardError }
|
20
|
+
expect {
|
21
|
+
plugin.load!
|
22
|
+
}.to output(/Unable to load plugin tty-console./).to_stdout
|
31
23
|
end
|
32
24
|
end
|
@@ -21,7 +21,7 @@ describe TTY::System::Editor, '#open' do
|
|
21
21
|
before { allow(editor).to receive(:command).and_return('vim') }
|
22
22
|
|
23
23
|
it 'invokes editor' do
|
24
|
-
invocable = double(:invocable, :
|
24
|
+
invocable = double(:invocable, invoke: nil)
|
25
25
|
expect(subject).to receive(:new).with(file).and_return(invocable)
|
26
26
|
editor.open(file)
|
27
27
|
end
|
@@ -2,34 +2,26 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe TTY::Terminal, '#
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
expect(terminal.home).to eql('/home/user')
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'defaults to user HOME environment' do
|
18
|
-
allow(ENV).to receive(:[]).with('HOME').and_return('/home/user')
|
19
|
-
expect(terminal.home).to eq('/home/user')
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'when failed to expand' do
|
23
|
-
before { allow(File).to receive(:expand_path).and_raise(RuntimeError) }
|
24
|
-
|
25
|
-
it 'returns C:/ on windows' do
|
26
|
-
allow(TTY::System).to receive(:windows?).and_return(true)
|
27
|
-
expect(terminal.home).to eql("C:/")
|
5
|
+
RSpec.describe TTY::Terminal::Home, '#find_home' do
|
6
|
+
context 'on unix' do
|
7
|
+
it "finds home" do
|
8
|
+
platform = spy(:windows? => false)
|
9
|
+
home = described_class.new(platform)
|
10
|
+
allow(home).to receive(:unix_home).and_return('/users/piotr')
|
11
|
+
allow(File).to receive(:expand_path).and_return('/users/piotr')
|
12
|
+
expect(home.find_home).to eq('/users/piotr')
|
13
|
+
expect(home).to have_received(:unix_home)
|
28
14
|
end
|
15
|
+
end
|
29
16
|
|
30
|
-
|
31
|
-
|
32
|
-
|
17
|
+
context 'on windows' do
|
18
|
+
it "finds home" do
|
19
|
+
platform = spy(:windows? => true)
|
20
|
+
home = described_class.new(platform)
|
21
|
+
allow(home).to receive(:windows_home).and_return('C:\Users\Piotr')
|
22
|
+
allow(File).to receive(:expand_path).and_return('C:\Users\Piotr')
|
23
|
+
expect(home.find_home).to eq('C:\Users\Piotr')
|
24
|
+
expect(home).to have_received(:windows_home)
|
33
25
|
end
|
34
26
|
end
|
35
27
|
end
|
data/spec/tty/tty_spec.rb
CHANGED
@@ -7,7 +7,7 @@ describe TTY do
|
|
7
7
|
|
8
8
|
it { expect(object.terminal).to be_instance_of(TTY::Terminal) }
|
9
9
|
|
10
|
-
it { expect(object.shell).to be_instance_of(TTY::Shell) }
|
10
|
+
#it { expect(object.shell).to be_instance_of(TTY::Shell) }
|
11
11
|
|
12
12
|
it { expect(object.system).to be(TTY::System) }
|
13
13
|
|
data/spec/tty/vector/new_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Murach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-pager
|
@@ -188,26 +188,13 @@ files:
|
|
188
188
|
- lib/tty/logger.rb
|
189
189
|
- lib/tty/plugins.rb
|
190
190
|
- lib/tty/plugins/plugin.rb
|
191
|
-
- lib/tty/shell.rb
|
192
|
-
- lib/tty/shell/distance.rb
|
193
|
-
- lib/tty/shell/question.rb
|
194
|
-
- lib/tty/shell/question/modifier.rb
|
195
|
-
- lib/tty/shell/question/validation.rb
|
196
|
-
- lib/tty/shell/reader.rb
|
197
|
-
- lib/tty/shell/response.rb
|
198
|
-
- lib/tty/shell/response_delegation.rb
|
199
|
-
- lib/tty/shell/statement.rb
|
200
|
-
- lib/tty/shell/suggestion.rb
|
201
191
|
- lib/tty/support/coercion.rb
|
202
192
|
- lib/tty/support/delegatable.rb
|
203
193
|
- lib/tty/support/unicode.rb
|
204
|
-
- lib/tty/support/utils.rb
|
205
194
|
- lib/tty/system.rb
|
206
195
|
- lib/tty/system/editor.rb
|
207
196
|
- lib/tty/terminal.rb
|
208
|
-
- lib/tty/terminal/echo.rb
|
209
197
|
- lib/tty/terminal/home.rb
|
210
|
-
- lib/tty/terminal/raw.rb
|
211
198
|
- lib/tty/vector.rb
|
212
199
|
- lib/tty/version.rb
|
213
200
|
- spec/spec_helper.rb
|
@@ -218,38 +205,6 @@ files:
|
|
218
205
|
- spec/tty/plugins/load_spec.rb
|
219
206
|
- spec/tty/plugins/plugin/load_spec.rb
|
220
207
|
- spec/tty/plugins/plugin/new_spec.rb
|
221
|
-
- spec/tty/shell/ask_spec.rb
|
222
|
-
- spec/tty/shell/distance/distance_spec.rb
|
223
|
-
- spec/tty/shell/distance/initialize_spec.rb
|
224
|
-
- spec/tty/shell/error_spec.rb
|
225
|
-
- spec/tty/shell/print_table_spec.rb
|
226
|
-
- spec/tty/shell/question/argument_spec.rb
|
227
|
-
- spec/tty/shell/question/character_spec.rb
|
228
|
-
- spec/tty/shell/question/default_spec.rb
|
229
|
-
- spec/tty/shell/question/in_spec.rb
|
230
|
-
- spec/tty/shell/question/initialize_spec.rb
|
231
|
-
- spec/tty/shell/question/modifier/apply_to_spec.rb
|
232
|
-
- spec/tty/shell/question/modifier/letter_case_spec.rb
|
233
|
-
- spec/tty/shell/question/modifier/whitespace_spec.rb
|
234
|
-
- spec/tty/shell/question/modify_spec.rb
|
235
|
-
- spec/tty/shell/question/valid_spec.rb
|
236
|
-
- spec/tty/shell/question/validate_spec.rb
|
237
|
-
- spec/tty/shell/question/validation/coerce_spec.rb
|
238
|
-
- spec/tty/shell/question/validation/valid_value_spec.rb
|
239
|
-
- spec/tty/shell/reader/getc_spec.rb
|
240
|
-
- spec/tty/shell/response/read_bool_spec.rb
|
241
|
-
- spec/tty/shell/response/read_char_spec.rb
|
242
|
-
- spec/tty/shell/response/read_date_spec.rb
|
243
|
-
- spec/tty/shell/response/read_email_spec.rb
|
244
|
-
- spec/tty/shell/response/read_multiple_spec.rb
|
245
|
-
- spec/tty/shell/response/read_number_spec.rb
|
246
|
-
- spec/tty/shell/response/read_range_spec.rb
|
247
|
-
- spec/tty/shell/response/read_spec.rb
|
248
|
-
- spec/tty/shell/response/read_string_spec.rb
|
249
|
-
- spec/tty/shell/say_spec.rb
|
250
|
-
- spec/tty/shell/statement/initialize_spec.rb
|
251
|
-
- spec/tty/shell/suggest_spec.rb
|
252
|
-
- spec/tty/shell/warn_spec.rb
|
253
208
|
- spec/tty/support/coercion_spec.rb
|
254
209
|
- spec/tty/support/delegatable_spec.rb
|
255
210
|
- spec/tty/support/fixtures/classes.rb
|
@@ -259,8 +214,6 @@ files:
|
|
259
214
|
- spec/tty/system/editor/executables_spec.rb
|
260
215
|
- spec/tty/system/editor/invoke_spec.rb
|
261
216
|
- spec/tty/system/editor/open_spec.rb
|
262
|
-
- spec/tty/terminal/color_spec.rb
|
263
|
-
- spec/tty/terminal/echo_spec.rb
|
264
217
|
- spec/tty/terminal/home_spec.rb
|
265
218
|
- spec/tty/tty_spec.rb
|
266
219
|
- spec/tty/vector/new_spec.rb
|
@@ -306,38 +259,6 @@ test_files:
|
|
306
259
|
- spec/tty/plugins/load_spec.rb
|
307
260
|
- spec/tty/plugins/plugin/load_spec.rb
|
308
261
|
- spec/tty/plugins/plugin/new_spec.rb
|
309
|
-
- spec/tty/shell/ask_spec.rb
|
310
|
-
- spec/tty/shell/distance/distance_spec.rb
|
311
|
-
- spec/tty/shell/distance/initialize_spec.rb
|
312
|
-
- spec/tty/shell/error_spec.rb
|
313
|
-
- spec/tty/shell/print_table_spec.rb
|
314
|
-
- spec/tty/shell/question/argument_spec.rb
|
315
|
-
- spec/tty/shell/question/character_spec.rb
|
316
|
-
- spec/tty/shell/question/default_spec.rb
|
317
|
-
- spec/tty/shell/question/in_spec.rb
|
318
|
-
- spec/tty/shell/question/initialize_spec.rb
|
319
|
-
- spec/tty/shell/question/modifier/apply_to_spec.rb
|
320
|
-
- spec/tty/shell/question/modifier/letter_case_spec.rb
|
321
|
-
- spec/tty/shell/question/modifier/whitespace_spec.rb
|
322
|
-
- spec/tty/shell/question/modify_spec.rb
|
323
|
-
- spec/tty/shell/question/valid_spec.rb
|
324
|
-
- spec/tty/shell/question/validate_spec.rb
|
325
|
-
- spec/tty/shell/question/validation/coerce_spec.rb
|
326
|
-
- spec/tty/shell/question/validation/valid_value_spec.rb
|
327
|
-
- spec/tty/shell/reader/getc_spec.rb
|
328
|
-
- spec/tty/shell/response/read_bool_spec.rb
|
329
|
-
- spec/tty/shell/response/read_char_spec.rb
|
330
|
-
- spec/tty/shell/response/read_date_spec.rb
|
331
|
-
- spec/tty/shell/response/read_email_spec.rb
|
332
|
-
- spec/tty/shell/response/read_multiple_spec.rb
|
333
|
-
- spec/tty/shell/response/read_number_spec.rb
|
334
|
-
- spec/tty/shell/response/read_range_spec.rb
|
335
|
-
- spec/tty/shell/response/read_spec.rb
|
336
|
-
- spec/tty/shell/response/read_string_spec.rb
|
337
|
-
- spec/tty/shell/say_spec.rb
|
338
|
-
- spec/tty/shell/statement/initialize_spec.rb
|
339
|
-
- spec/tty/shell/suggest_spec.rb
|
340
|
-
- spec/tty/shell/warn_spec.rb
|
341
262
|
- spec/tty/support/coercion_spec.rb
|
342
263
|
- spec/tty/support/delegatable_spec.rb
|
343
264
|
- spec/tty/support/fixtures/classes.rb
|
@@ -347,8 +268,6 @@ test_files:
|
|
347
268
|
- spec/tty/system/editor/executables_spec.rb
|
348
269
|
- spec/tty/system/editor/invoke_spec.rb
|
349
270
|
- spec/tty/system/editor/open_spec.rb
|
350
|
-
- spec/tty/terminal/color_spec.rb
|
351
|
-
- spec/tty/terminal/echo_spec.rb
|
352
271
|
- spec/tty/terminal/home_spec.rb
|
353
272
|
- spec/tty/tty_spec.rb
|
354
273
|
- spec/tty/vector/new_spec.rb
|
data/lib/tty/shell.rb
DELETED
@@ -1,211 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module TTY
|
4
|
-
# A class responsible for shell prompt interactions.
|
5
|
-
class Shell
|
6
|
-
# @api private
|
7
|
-
attr_reader :input
|
8
|
-
|
9
|
-
# @api private
|
10
|
-
attr_reader :output
|
11
|
-
|
12
|
-
# Shell prompt prefix
|
13
|
-
#
|
14
|
-
# @api private
|
15
|
-
attr_reader :prefix
|
16
|
-
|
17
|
-
# Initialize a Shell
|
18
|
-
#
|
19
|
-
# @api public
|
20
|
-
def initialize(input = stdin, output = stdout, options = {})
|
21
|
-
@input = input
|
22
|
-
@output = output
|
23
|
-
@prefix = options.fetch(:prefix) { '' }
|
24
|
-
end
|
25
|
-
|
26
|
-
# Ask a question.
|
27
|
-
#
|
28
|
-
# @example
|
29
|
-
# shell = TTY::Shell.new
|
30
|
-
# shell.ask("What is your name?")
|
31
|
-
#
|
32
|
-
# @param [String] statement
|
33
|
-
# string question to be asked
|
34
|
-
#
|
35
|
-
# @yieldparam [TTY::Question] question
|
36
|
-
# further configure the question
|
37
|
-
#
|
38
|
-
# @yield [question]
|
39
|
-
#
|
40
|
-
# @return [TTY::Question]
|
41
|
-
#
|
42
|
-
# @api public
|
43
|
-
def ask(statement, *args, &block)
|
44
|
-
options = Utils.extract_options!(args)
|
45
|
-
|
46
|
-
question = Question.new self, options
|
47
|
-
question.instance_eval(&block) if block_given?
|
48
|
-
question.prompt(statement)
|
49
|
-
end
|
50
|
-
|
51
|
-
# A shortcut method to ask the user positive question and return
|
52
|
-
# true for 'yes' reply.
|
53
|
-
#
|
54
|
-
# @return [Boolean]
|
55
|
-
#
|
56
|
-
# @api public
|
57
|
-
def yes?(statement, *args, &block)
|
58
|
-
ask(statement, *args, &block).read_bool
|
59
|
-
end
|
60
|
-
|
61
|
-
# A shortcut method to ask the user negative question and return
|
62
|
-
# true for 'no' reply.
|
63
|
-
#
|
64
|
-
# @return [Boolean]
|
65
|
-
#
|
66
|
-
# @api public
|
67
|
-
def no?(statement, *args, &block)
|
68
|
-
!yes?(statement, *args, &block)
|
69
|
-
end
|
70
|
-
|
71
|
-
# Print statement out. If the supplied message ends with a space or
|
72
|
-
# tab character, a new line will not be appended.
|
73
|
-
#
|
74
|
-
# @example
|
75
|
-
# say("Simple things.")
|
76
|
-
#
|
77
|
-
# @param [String] message
|
78
|
-
#
|
79
|
-
# @return [String]
|
80
|
-
#
|
81
|
-
# @api public
|
82
|
-
def say(message = '', options = {})
|
83
|
-
message = message.to_str
|
84
|
-
return unless message.length > 0
|
85
|
-
|
86
|
-
statement = Statement.new(self, options)
|
87
|
-
statement.declare message
|
88
|
-
end
|
89
|
-
|
90
|
-
# Print statement(s) out in red green.
|
91
|
-
#
|
92
|
-
# @example
|
93
|
-
# shell.confirm "Are you sure?"
|
94
|
-
# shell.confirm "All is fine!", "This is fine too."
|
95
|
-
#
|
96
|
-
# @param [Array] messages
|
97
|
-
#
|
98
|
-
# @return [Array] messages
|
99
|
-
#
|
100
|
-
# @api public
|
101
|
-
def confirm(*args)
|
102
|
-
options = Utils.extract_options!(args)
|
103
|
-
args.each { |message| say message, options.merge(color: :green) }
|
104
|
-
end
|
105
|
-
|
106
|
-
# Print statement(s) out in yellow color.
|
107
|
-
#
|
108
|
-
# @example
|
109
|
-
# shell.warn "This action can have dire consequences"
|
110
|
-
# shell.warn "Carefull young apprentice", "This is potentially dangerous"
|
111
|
-
#
|
112
|
-
# @param [Array] messages
|
113
|
-
#
|
114
|
-
# @return [Array] messages
|
115
|
-
#
|
116
|
-
# @api public
|
117
|
-
def warn(*args)
|
118
|
-
options = Utils.extract_options!(args)
|
119
|
-
args.each { |message| say message, options.merge(color: :yellow) }
|
120
|
-
end
|
121
|
-
|
122
|
-
# Print statement(s) out in red color.
|
123
|
-
#
|
124
|
-
# @example
|
125
|
-
# shell.error "Shutting down all systems!"
|
126
|
-
# shell.error "Nothing is fine!", "All is broken!"
|
127
|
-
#
|
128
|
-
# @param [Array] messages
|
129
|
-
#
|
130
|
-
# @return [Array] messages
|
131
|
-
#
|
132
|
-
# @api public
|
133
|
-
def error(*args)
|
134
|
-
options = Utils.extract_options!(args)
|
135
|
-
args.each { |message| say message, options.merge(color: :red) }
|
136
|
-
end
|
137
|
-
|
138
|
-
# Takes the string provided by the user and compare it with other possible
|
139
|
-
# matches to suggest an unambigous string
|
140
|
-
#
|
141
|
-
# @example
|
142
|
-
# shell.suggest('sta', ['status', 'stage', 'commit', 'branch'])
|
143
|
-
# # => "status, stage"
|
144
|
-
#
|
145
|
-
# @param [String] message
|
146
|
-
#
|
147
|
-
# @param [Array] possibilities
|
148
|
-
#
|
149
|
-
# @param [Hash] options
|
150
|
-
# @option options [String] :indent
|
151
|
-
# The number of spaces for indentation
|
152
|
-
# @option options [String] :single_text
|
153
|
-
# The text for a single suggestion
|
154
|
-
# @option options [String] :plural_text
|
155
|
-
# The text for multiple suggestions
|
156
|
-
#
|
157
|
-
# @return [String]
|
158
|
-
#
|
159
|
-
# @api public
|
160
|
-
def suggest(message, possibilities, options = {})
|
161
|
-
suggestion = Suggestion.new(options)
|
162
|
-
say(suggestion.suggest(message, possibilities))
|
163
|
-
end
|
164
|
-
|
165
|
-
# Print a table to shell.
|
166
|
-
#
|
167
|
-
# @example of a table with rows rendered with ascii border
|
168
|
-
# rows = [[1], [2], [3]]
|
169
|
-
# TTY.shell.print_table rows, renderer: :ascii
|
170
|
-
#
|
171
|
-
# @return [undefined]
|
172
|
-
#
|
173
|
-
# @api public
|
174
|
-
def print_table(*args, &block)
|
175
|
-
options = Utils.extract_options!(args)
|
176
|
-
renderer = options.fetch(:renderer) { :basic }
|
177
|
-
table = TTY::Table.new(*args, &block)
|
178
|
-
say table.render(renderer, options)
|
179
|
-
end
|
180
|
-
|
181
|
-
# Check if outputing to shell
|
182
|
-
#
|
183
|
-
# @return [Boolean]
|
184
|
-
#
|
185
|
-
# @api public
|
186
|
-
def tty?
|
187
|
-
stdout.tty?
|
188
|
-
end
|
189
|
-
|
190
|
-
# Return standard in
|
191
|
-
#
|
192
|
-
# @api private
|
193
|
-
def stdin
|
194
|
-
$stdin
|
195
|
-
end
|
196
|
-
|
197
|
-
# Return standard out
|
198
|
-
#
|
199
|
-
# @api private
|
200
|
-
def stdout
|
201
|
-
$stdout
|
202
|
-
end
|
203
|
-
|
204
|
-
# Return standard error
|
205
|
-
#
|
206
|
-
# @api private
|
207
|
-
def stderr
|
208
|
-
$stderr
|
209
|
-
end
|
210
|
-
end # Shell
|
211
|
-
end # TTY
|