ruby_jard 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +32 -0
  3. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  4. data/.github/workflows/ruby.yml +85 -0
  5. data/.gitignore +1 -0
  6. data/.rubocop.yml +70 -1
  7. data/CHANGELOG.md +31 -0
  8. data/Gemfile +6 -3
  9. data/README.md +122 -8
  10. data/bin/console +1 -2
  11. data/docs/color_schemes/256-light.png +0 -0
  12. data/docs/color_schemes/gruvbox.png +0 -0
  13. data/docs/color_schemes/one-half-dark.png +0 -0
  14. data/docs/color_schemes/one-half-light.png +0 -0
  15. data/lib/ruby_jard.rb +5 -5
  16. data/lib/ruby_jard/box_drawer.rb +4 -1
  17. data/lib/ruby_jard/color_schemes.rb +31 -15
  18. data/lib/ruby_jard/color_schemes/256_color_scheme.rb +37 -37
  19. data/lib/ruby_jard/color_schemes/256_light_color_scheme.rb +62 -0
  20. data/lib/ruby_jard/color_schemes/deep_space_color_scheme.rb +36 -36
  21. data/lib/ruby_jard/color_schemes/gruvbox_color_scheme.rb +62 -0
  22. data/lib/ruby_jard/color_schemes/one_half_dark_color_scheme.rb +61 -0
  23. data/lib/ruby_jard/color_schemes/one_half_light_color_scheme.rb +62 -0
  24. data/lib/ruby_jard/column.rb +3 -1
  25. data/lib/ruby_jard/commands/continue_command.rb +2 -3
  26. data/lib/ruby_jard/commands/down_command.rb +9 -5
  27. data/lib/ruby_jard/commands/exit_command.rb +27 -0
  28. data/lib/ruby_jard/commands/frame_command.rb +11 -10
  29. data/lib/ruby_jard/commands/jard/color_scheme_command.rb +52 -0
  30. data/lib/ruby_jard/commands/jard/hide_command.rb +40 -0
  31. data/lib/ruby_jard/commands/jard/output_command.rb +28 -0
  32. data/lib/ruby_jard/commands/jard/show_command.rb +41 -0
  33. data/lib/ruby_jard/commands/jard_command.rb +50 -0
  34. data/lib/ruby_jard/commands/list_command.rb +5 -4
  35. data/lib/ruby_jard/commands/next_command.rb +10 -5
  36. data/lib/ruby_jard/commands/step_command.rb +10 -5
  37. data/lib/ruby_jard/commands/step_out_command.rb +10 -5
  38. data/lib/ruby_jard/commands/up_command.rb +10 -5
  39. data/lib/ruby_jard/commands/validation_helpers.rb +50 -0
  40. data/lib/ruby_jard/config.rb +7 -3
  41. data/lib/ruby_jard/console.rb +10 -22
  42. data/lib/ruby_jard/control_flow.rb +3 -3
  43. data/lib/ruby_jard/decorators/color_decorator.rb +11 -5
  44. data/lib/ruby_jard/decorators/loc_decorator.rb +1 -1
  45. data/lib/ruby_jard/decorators/path_decorator.rb +20 -7
  46. data/lib/ruby_jard/decorators/source_decorator.rb +2 -0
  47. data/lib/ruby_jard/frame.rb +55 -0
  48. data/lib/ruby_jard/keys.rb +0 -3
  49. data/lib/ruby_jard/layout.rb +9 -2
  50. data/lib/ruby_jard/layout_calculator.rb +29 -12
  51. data/lib/ruby_jard/layout_picker.rb +34 -0
  52. data/lib/ruby_jard/layouts.rb +52 -0
  53. data/lib/ruby_jard/layouts/narrow_horizontal_layout.rb +28 -0
  54. data/lib/ruby_jard/layouts/narrow_vertical_layout.rb +32 -0
  55. data/lib/ruby_jard/layouts/tiny_layout.rb +25 -0
  56. data/lib/ruby_jard/layouts/wide_layout.rb +13 -15
  57. data/lib/ruby_jard/pager.rb +96 -0
  58. data/lib/ruby_jard/repl_processor.rb +61 -31
  59. data/lib/ruby_jard/repl_proxy.rb +193 -89
  60. data/lib/ruby_jard/row.rb +16 -1
  61. data/lib/ruby_jard/row_renderer.rb +51 -42
  62. data/lib/ruby_jard/screen.rb +2 -12
  63. data/lib/ruby_jard/screen_adjuster.rb +104 -0
  64. data/lib/ruby_jard/screen_drawer.rb +3 -0
  65. data/lib/ruby_jard/screen_manager.rb +32 -54
  66. data/lib/ruby_jard/screen_renderer.rb +30 -16
  67. data/lib/ruby_jard/screens.rb +31 -12
  68. data/lib/ruby_jard/screens/backtrace_screen.rb +23 -26
  69. data/lib/ruby_jard/screens/menu_screen.rb +53 -22
  70. data/lib/ruby_jard/screens/source_screen.rb +65 -37
  71. data/lib/ruby_jard/screens/threads_screen.rb +14 -14
  72. data/lib/ruby_jard/screens/variables_screen.rb +59 -34
  73. data/lib/ruby_jard/session.rb +19 -10
  74. data/lib/ruby_jard/span.rb +3 -0
  75. data/lib/ruby_jard/templates/layout_template.rb +1 -1
  76. data/lib/ruby_jard/templates/screen_template.rb +3 -4
  77. data/lib/ruby_jard/version.rb +1 -1
  78. data/ruby_jard.gemspec +1 -1
  79. metadata +38 -9
  80. data/lib/ruby_jard/commands/color_scheme_command.rb +0 -42
  81. data/lib/ruby_jard/layouts/narrow_layout.rb +0 -41
  82. data/lib/ruby_jard/screens/empty_screen.rb +0 -13
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyJard
4
- module Screens
4
+ class Screens
5
+ ##
6
+ # Display the relevant variables and constants of current context, scopes
5
7
  class VariablesScreen < RubyJard::Screen
6
8
  TYPE_SYMBOLS = {
7
9
  # Intertal classes for those values may differ between Ruby versions
@@ -24,12 +26,21 @@ module RubyJard
24
26
  DEFAULT_TYPE_SYMBOL = :var
25
27
 
26
28
  KINDS = [
27
- KIND_LOC = :local_variable,
28
- KIND_INS = :instance_variable,
29
- KIND_CON = :constant
29
+ KIND_LOC = :local_variable,
30
+ KIND_INS = :instance_variable,
31
+ KIND_CON = :constant,
32
+ KIND_SELF = :self
30
33
  ].freeze
31
34
 
35
+ KIND_STYLES = {
36
+ KIND_LOC => :local_variable,
37
+ KIND_INS => :instance_variable,
38
+ KIND_CON => :constant,
39
+ KIND_SELF => :constant
40
+ }.freeze
41
+
32
42
  KIND_PRIORITIES = {
43
+ KIND_SELF => 0,
33
44
  KIND_LOC => 1,
34
45
  KIND_INS => 2,
35
46
  KIND_CON => 3
@@ -47,7 +58,11 @@ module RubyJard
47
58
  end
48
59
 
49
60
  def build
50
- variables = fetch_local_variables + fetch_instance_variables + fetch_constants
61
+ variables =
62
+ self_variable +
63
+ fetch_local_variables +
64
+ fetch_instance_variables +
65
+ fetch_constants
51
66
  variables = sort_variables(variables)
52
67
  @rows = variables.map do |variable|
53
68
  RubyJard::Row.new(
@@ -90,7 +105,7 @@ module RubyJard
90
105
  RubyJard::Span.new(
91
106
  margin_right: 1,
92
107
  content: variable[1].to_s,
93
- styles: variable[0].to_sym
108
+ styles: KIND_STYLES[variable[0].to_sym]
94
109
  )
95
110
  end
96
111
 
@@ -112,8 +127,15 @@ module RubyJard
112
127
  end
113
128
 
114
129
  def span_inspection(variable)
130
+ inspection =
131
+ case variable[0]
132
+ when KIND_SELF
133
+ variable[2].to_s
134
+ else
135
+ variable[2].inspect
136
+ end
115
137
  # Hard limit: screen area
116
- inspection = variable[2].inspect[0..@layout.height * @layout.width]
138
+ inspection = inspection[0..@layout.height * @layout.width]
117
139
  # TODO: This is just a workable. Should write a decorator to inspect objects accurately
118
140
  ["\n", "\r", "\r\n"].each do |esc|
119
141
  inspection.gsub!(esc, esc.inspect)
@@ -122,46 +144,35 @@ module RubyJard
122
144
  content: inspection,
123
145
  styles: :variable_inspection
124
146
  )
147
+ rescue StandardError
148
+ RubyJard::Span.new(
149
+ content: '<Fail to inspect>',
150
+ styles: :variable_inspection
151
+ )
125
152
  end
126
153
 
127
154
  private
128
155
 
129
- def current_binding
130
- RubyJard.current_session.frame._binding
131
- end
132
-
133
- def current_frame
134
- RubyJard.current_session.frame
135
- end
136
-
137
- def current_frame_scope
138
- RubyJard.current_session.backtrace[RubyJard.current_session.frame.pos][1]
139
- end
140
-
141
- def current_frame_scope_class
142
- RubyJard.current_session.backtrace[RubyJard.current_session.frame.pos][2]
143
- end
144
-
145
156
  def fetch_local_variables
146
- variables = current_binding.local_variables
157
+ variables = @session.current_frame.frame_binding.local_variables
147
158
  # Exclude Pry's sticky locals
148
159
  pry_sticky_locals =
149
160
  if variables.include?(:pry_instance)
150
- current_binding.local_variable_get(:pry_instance).sticky_locals.keys
161
+ @session.current_frame.frame_binding.local_variable_get(:pry_instance).sticky_locals.keys
151
162
  else
152
163
  []
153
164
  end
154
165
  variables -= pry_sticky_locals
155
166
  variables.map do |variable|
156
- [KIND_LOC, variable, current_binding.local_variable_get(variable)]
167
+ [KIND_LOC, variable, @session.current_frame.frame_binding.local_variable_get(variable)]
157
168
  rescue NameError
158
169
  nil
159
170
  end.compact
160
171
  end
161
172
 
162
173
  def fetch_instance_variables
163
- current_frame_scope.instance_variables.map do |variable|
164
- [KIND_INS, variable, current_frame_scope.instance_variable_get(variable)]
174
+ @session.current_frame.frame_self.instance_variables.map do |variable|
175
+ [KIND_INS, variable, @session.current_frame.frame_self.instance_variable_get(variable)]
165
176
  rescue NameError
166
177
  nil
167
178
  end.compact
@@ -170,13 +181,14 @@ module RubyJard
170
181
  def fetch_constants
171
182
  # Filter out truly constants (CONSTANT convention) only
172
183
  constant_source =
173
- if current_frame_scope_class&.singleton_class?
174
- current_frame_scope
184
+ if @session.current_frame.frame_class&.singleton_class?
185
+ @session.current_frame.frame_self
175
186
  else
176
- current_frame_scope_class
187
+ @session.current_frame.frame_class
177
188
  end
178
189
 
179
190
  return [] unless constant_source.respond_to?(:constants)
191
+ return [] if toplevel_binding?
180
192
 
181
193
  constants = constant_source.constants.select { |v| v.to_s.upcase == v.to_s }
182
194
  constants.map do |variable|
@@ -188,6 +200,18 @@ module RubyJard
188
200
  end.compact
189
201
  end
190
202
 
203
+ def toplevel_binding?
204
+ @session.current_frame.frame_self == TOPLEVEL_BINDING.receiver
205
+ rescue StandardError
206
+ false
207
+ end
208
+
209
+ def self_variable
210
+ [[KIND_SELF, :self, @session.current_frame.frame_self]]
211
+ rescue StandardError
212
+ []
213
+ end
214
+
191
215
  def sort_variables(variables)
192
216
  # Sort by kind
193
217
  # Sort by "internal" character so that internal variable is pushed down
@@ -219,8 +243,8 @@ module RubyJard
219
243
  def inline_tokens
220
244
  return @inline_tokens if defined?(@inline_tokens)
221
245
 
222
- current_file = RubyJard.current_session.frame.file
223
- current_line = RubyJard.current_session.frame.line
246
+ current_file = @session.current_frame.frame_file
247
+ current_line = @session.current_frame.frame_line
224
248
  source_decorator = RubyJard::Decorators::SourceDecorator.new(current_file, current_line, 1)
225
249
  _spans, tokens = loc_decorator.decorate(
226
250
  source_decorator.codes[current_line - source_decorator.window_start],
@@ -237,6 +261,7 @@ module RubyJard
237
261
 
238
262
  @inline_tokens
239
263
  end
264
+
240
265
  def loc_decorator
241
266
  @loc_decorator ||= RubyJard::Decorators::LocDecorator.new
242
267
  end
@@ -244,4 +269,4 @@ module RubyJard
244
269
  end
245
270
  end
246
271
 
247
- RubyJard::Screens.add_screen(:variables, RubyJard::Screens::VariablesScreen)
272
+ RubyJard::Screens.add_screen('variables', RubyJard::Screens::VariablesScreen)
@@ -11,17 +11,16 @@ module RubyJard
11
11
  # other processes. Therefore, an internal, jard-specific data mapping should
12
12
  # be built.
13
13
  class Session
14
- attr_reader :backtrace, :frame, :contexts, :current_context
14
+ attr_accessor :threads, :current_frame, :current_backtrace
15
15
 
16
16
  def initialize(options = {})
17
17
  @options = options
18
-
19
- @backtrace = []
20
- @frame = nil
21
- @contexts = []
22
-
23
18
  @started = false
24
19
  @session_lock = Mutex.new
20
+
21
+ @current_frame = nil
22
+ @current_backtrace = []
23
+ @threads = []
25
24
  end
26
25
 
27
26
  def start
@@ -54,13 +53,23 @@ module RubyJard
54
53
  start unless started?
55
54
 
56
55
  Byebug.attach
57
- Byebug.current_context.step_out(2, false)
56
+ Byebug.current_context.step_out(3, true)
58
57
  end
59
58
 
60
59
  def update
61
- @backtrace = Byebug.current_context.backtrace
62
- @frame = Byebug.current_context.frame
63
- @contexts = Byebug.contexts
60
+ current_context = Byebug.current_context
61
+ @current_frame = RubyJard::Frame.new(current_context, current_context.frame.pos)
62
+ @current_backtrace = current_context.backtrace.map.with_index do |_frame, index|
63
+ RubyJard::Frame.new(current_context, index)
64
+ end
65
+ @threads =
66
+ Byebug
67
+ .contexts
68
+ .reject(&:ignored?)
69
+ .reject { |c| c.thread.name.to_s =~ /<<Jard:.*>>/ }
70
+ .map do |context|
71
+ RubyJard::Frame.new(context, 0)
72
+ end
64
73
  end
65
74
 
66
75
  def lock
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyJard
4
+ ##
5
+ # Smallest unit of texts. A span includes content, margin, and styles of a particular
6
+ # text chunk. All decorators and presenters return single/a list of spans.
4
7
  class Span
5
8
  extend Forwardable
6
9
 
@@ -18,7 +18,7 @@ module RubyJard
18
18
  min_width: nil, min_height: nil,
19
19
  height: nil, width: nil,
20
20
  children: [],
21
- fill_width: nil, fill_height: nil
21
+ fill_width: true, fill_height: true
22
22
  )
23
23
  @height_ratio = height_ratio
24
24
  @width_ratio = width_ratio
@@ -9,7 +9,7 @@ module RubyJard
9
9
  attr_reader :screen, :row_template, :height_ratio, :width_ratio,
10
10
  :min_width, :min_height,
11
11
  :height, :width,
12
- :fill_width, :fill_height
12
+ :adjust_mode
13
13
 
14
14
  def initialize(
15
15
  screen: nil,
@@ -17,7 +17,7 @@ module RubyJard
17
17
  height_ratio: nil, width_ratio: nil,
18
18
  min_width: nil, min_height: nil,
19
19
  height: nil, width: nil,
20
- fill_width: nil, fill_height: nil
20
+ adjust_mode: nil
21
21
  )
22
22
  @screen = screen
23
23
  @row_template = row_template
@@ -27,8 +27,7 @@ module RubyJard
27
27
  @min_height = min_height
28
28
  @height = height
29
29
  @width = width
30
- @fill_width = fill_width
31
- @fill_height = fill_height
30
+ @adjust_mode = adjust_mode
32
31
  end
33
32
  end
34
33
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Semantic versionn
4
4
  module RubyJard
5
- VERSION = '0.2.2'
5
+ VERSION = '0.2.3'
6
6
  end
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = []
31
31
  spec.require_paths = ['lib']
32
32
 
33
- spec.add_runtime_dependency 'byebug', '~> 11.1.0'
33
+ spec.add_runtime_dependency 'byebug', '>= 9.1', '< 12.0'
34
34
  spec.add_runtime_dependency 'pry', '~> 0.13.0'
35
35
  spec.add_runtime_dependency 'tty-screen', '~> 0.8.1'
36
36
  end
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_jard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minh Nguyen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-04 00:00:00.000000000 Z
11
+ date: 2020-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '9.1'
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: 11.1.0
22
+ version: '12.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '9.1'
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: 11.1.0
32
+ version: '12.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: pry
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -61,6 +67,9 @@ executables: []
61
67
  extensions: []
62
68
  extra_rdoc_files: []
63
69
  files:
70
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
71
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
72
+ - ".github/workflows/ruby.yml"
64
73
  - ".gitignore"
65
74
  - ".rspec"
66
75
  - ".rubocop.yml"
@@ -75,8 +84,12 @@ files:
75
84
  - _config.yml
76
85
  - bin/console
77
86
  - docs/_config.yml
87
+ - docs/color_schemes/256-light.png
78
88
  - docs/color_schemes/256.png
79
89
  - docs/color_schemes/deep-space.png
90
+ - docs/color_schemes/gruvbox.png
91
+ - docs/color_schemes/one-half-dark.png
92
+ - docs/color_schemes/one-half-light.png
80
93
  - docs/demo.png
81
94
  - docs/guide-ui.png
82
95
  - docs/index.md
@@ -102,17 +115,27 @@ files:
102
115
  - lib/ruby_jard/color_scheme.rb
103
116
  - lib/ruby_jard/color_schemes.rb
104
117
  - lib/ruby_jard/color_schemes/256_color_scheme.rb
118
+ - lib/ruby_jard/color_schemes/256_light_color_scheme.rb
105
119
  - lib/ruby_jard/color_schemes/deep_space_color_scheme.rb
120
+ - lib/ruby_jard/color_schemes/gruvbox_color_scheme.rb
121
+ - lib/ruby_jard/color_schemes/one_half_dark_color_scheme.rb
122
+ - lib/ruby_jard/color_schemes/one_half_light_color_scheme.rb
106
123
  - lib/ruby_jard/column.rb
107
- - lib/ruby_jard/commands/color_scheme_command.rb
108
124
  - lib/ruby_jard/commands/continue_command.rb
109
125
  - lib/ruby_jard/commands/down_command.rb
126
+ - lib/ruby_jard/commands/exit_command.rb
110
127
  - lib/ruby_jard/commands/frame_command.rb
128
+ - lib/ruby_jard/commands/jard/color_scheme_command.rb
129
+ - lib/ruby_jard/commands/jard/hide_command.rb
130
+ - lib/ruby_jard/commands/jard/output_command.rb
131
+ - lib/ruby_jard/commands/jard/show_command.rb
132
+ - lib/ruby_jard/commands/jard_command.rb
111
133
  - lib/ruby_jard/commands/list_command.rb
112
134
  - lib/ruby_jard/commands/next_command.rb
113
135
  - lib/ruby_jard/commands/step_command.rb
114
136
  - lib/ruby_jard/commands/step_out_command.rb
115
137
  - lib/ruby_jard/commands/up_command.rb
138
+ - lib/ruby_jard/commands/validation_helpers.rb
116
139
  - lib/ruby_jard/config.rb
117
140
  - lib/ruby_jard/console.rb
118
141
  - lib/ruby_jard/control_flow.rb
@@ -121,24 +144,30 @@ files:
121
144
  - lib/ruby_jard/decorators/loc_decorator.rb
122
145
  - lib/ruby_jard/decorators/path_decorator.rb
123
146
  - lib/ruby_jard/decorators/source_decorator.rb
147
+ - lib/ruby_jard/frame.rb
124
148
  - lib/ruby_jard/key_binding.rb
125
149
  - lib/ruby_jard/key_bindings.rb
126
150
  - lib/ruby_jard/keys.rb
127
151
  - lib/ruby_jard/layout.rb
128
152
  - lib/ruby_jard/layout_calculator.rb
129
- - lib/ruby_jard/layouts/narrow_layout.rb
153
+ - lib/ruby_jard/layout_picker.rb
154
+ - lib/ruby_jard/layouts.rb
155
+ - lib/ruby_jard/layouts/narrow_horizontal_layout.rb
156
+ - lib/ruby_jard/layouts/narrow_vertical_layout.rb
157
+ - lib/ruby_jard/layouts/tiny_layout.rb
130
158
  - lib/ruby_jard/layouts/wide_layout.rb
159
+ - lib/ruby_jard/pager.rb
131
160
  - lib/ruby_jard/repl_processor.rb
132
161
  - lib/ruby_jard/repl_proxy.rb
133
162
  - lib/ruby_jard/row.rb
134
163
  - lib/ruby_jard/row_renderer.rb
135
164
  - lib/ruby_jard/screen.rb
165
+ - lib/ruby_jard/screen_adjuster.rb
136
166
  - lib/ruby_jard/screen_drawer.rb
137
167
  - lib/ruby_jard/screen_manager.rb
138
168
  - lib/ruby_jard/screen_renderer.rb
139
169
  - lib/ruby_jard/screens.rb
140
170
  - lib/ruby_jard/screens/backtrace_screen.rb
141
- - lib/ruby_jard/screens/empty_screen.rb
142
171
  - lib/ruby_jard/screens/menu_screen.rb
143
172
  - lib/ruby_jard/screens/source_screen.rb
144
173
  - lib/ruby_jard/screens/threads_screen.rb
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RubyJard
4
- module Commands
5
- # Command used to explore stacktrace.
6
- class ColorSchemeCommand < Pry::ClassCommand
7
- group 'RubyJard'
8
- description 'Control the color scheme used in Jard'
9
-
10
- match 'color-scheme'
11
-
12
- banner <<-BANNER
13
- Usage: color-scheme -l
14
- color-scheme [scheme-name]
15
- BANNER
16
-
17
- def options(opt)
18
- opt.on :l, :list, "List all available color schemes"
19
- end
20
-
21
- def process
22
- if opts[:l]
23
- if args.length != 0
24
- raise Pry::CommandError, "Color scheme list command shouldn't have any argument."
25
- end
26
- pry_instance.pager.page RubyJard::ColorSchemes.names.join("\n")
27
- else
28
- color_scheme = args.first.to_s.strip
29
- if color_scheme.empty?
30
- raise Pry::CommandError, "You must provide a color scheme name."
31
- end
32
- if RubyJard::ColorSchemes[color_scheme].nil?
33
- raise Pry::CommandError, "Color scheme `#{color_scheme}` not found. Please use `color-scheme -l` to list all color schemes."
34
- end
35
- RubyJard::ControlFlow.dispatch(:color_scheme, color_scheme: color_scheme)
36
- end
37
- end
38
- end
39
- end
40
- end
41
-
42
- Pry::Commands.add_command(RubyJard::Commands::ColorSchemeCommand)