byebug 1.0.1 → 1.0.2

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.
@@ -78,6 +78,17 @@ module Byebug
78
78
  return call_str
79
79
  end
80
80
 
81
+ def print_backtrace
82
+ (0...@state.context.stack_size).each do |idx|
83
+ if idx == @state.frame_pos
84
+ print "--> "
85
+ else
86
+ print " "
87
+ end
88
+ print_frame(idx)
89
+ end
90
+ end
91
+
81
92
  def print_frame(pos, adjust = false, context=@state.context)
82
93
  file = context.frame_file(pos)
83
94
  line = context.frame_line(pos)
@@ -91,12 +102,12 @@ module Byebug
91
102
  end
92
103
  end
93
104
 
94
- frame_num = "##{pos}"
105
+ frame_num = "##{pos} "
95
106
  call_str = get_frame_call(frame_num, pos, context)
96
- file_line = "at line #{CommandProcessor.canonic_file(file)}:#{line}\n"
107
+ file_line = "at #{CommandProcessor.canonic_file(file)}:#{line}\n"
97
108
  print frame_num
98
109
  unless call_str.empty?
99
- print call_str
110
+ print "#{call_str} "
100
111
  if call_str.size + frame_num.size + file_line.size > self.class.settings[:width]
101
112
  print "\n "
102
113
  end
@@ -159,17 +170,9 @@ module Byebug
159
170
  end
160
171
 
161
172
  def execute
162
- (0...@state.context.stack_size).each do |idx|
163
- if idx == @state.frame_pos
164
- print "--> "
165
- else
166
- print " "
167
- end
168
- print_frame(idx)
169
-
170
- end
173
+ print_backtrace
171
174
  if truncated_callstack?(@state.context, Byebug.start_sentinal)
172
- # print "Warning: saved frames may be incomplete; compare with caller(0).\n"
175
+ print "Warning: saved frames may be incomplete; compare with caller(0).\n"
173
176
  end
174
177
  end
175
178
 
@@ -182,17 +185,19 @@ module Byebug
182
185
  s = if cmd == 'where'
183
186
  %{
184
187
  w[here]\tdisplay stack frames
185
- }
188
+ }
186
189
  else
187
190
  %{
188
191
  bt|backtrace\t\talias for where - display stack frames
189
- }
192
+ }
190
193
  end
191
194
  s += %{
192
- Print the entire stack frame. Each frame is numbered, the most recent
193
- frame is 0. frame number can be referred to in the "frame" command;
194
- "up" and "down" add or subtract respectively to frame numbers shown.
195
- The position of the current frame is marked with -->. }
195
+ Print the entire stack frame. Each frame is numbered, the most
196
+ recent frame is 0. frame number can be referred to in the "frame"
197
+ command; "up" and "down" add or subtract respectively to frame
198
+ numbers shown. The position of the current frame is marked with
199
+ -->.
200
+ }
196
201
  end
197
202
  end
198
203
  end
@@ -14,53 +14,55 @@ module Byebug
14
14
  print "No exceptions set to be caught.\n"
15
15
  end
16
16
  end
17
-
18
17
  end
19
18
 
20
19
  # Implements byebug "info" command.
21
20
  class InfoCommand < Command
22
21
  self.allow_in_control = true
23
- Subcommands = [
24
- ['args', 1, 'Argument variables of current stack frame'],
25
- ['breakpoints', 1, 'Status of user-settable breakpoints',
26
- 'Without argument, list info about all breakpoints. With an integer ' \
27
- 'argument, list info on that breakpoint.'],
28
- ['catch', 3, 'Exceptions that can be caught in the current stack frame'],
29
- ['display', 2, 'Expressions to display when program stops'],
30
- ['file', 4, 'Info about a particular file read in',
31
- 'After the file name is supplied, you can list file attributes that ' \
32
- 'you wish to see. Attributes include: "all", "basic", "breakpoint", ' \
33
- '"lines", "mtime", "path" and "sha1".'],
34
- ['files', 5, 'File names and timestamps of files read in'],
35
- ['global_variables', 2, 'Global variables'],
36
- ['instance_variables', 2,
37
- 'Instance variables of the current stack frame'],
38
- ['line', 2,
39
- 'Line number and file name of current position in source file'],
40
- ['locals', 2, 'Local variables of the current stack frame'],
41
- ['program', 2, 'Execution status of the program'],
42
- ['stack', 2, 'Backtrace of the stack'],
43
- # ['thread', 6, 'List info about thread NUM',
44
- # 'If no thread number is given, we list info for all threads. ' \
45
- # '\'terse\' and \'verbose\' options are possible. If \'terse\', just ' \
46
- # 'give summary thread name information. See "help info threads" for ' \
47
- # 'more detail about this summary information. If \'verbose\' appended ' \
48
- # 'to the end of the command, then the entire stack trace is given for ' \
49
- # 'each thread.'],
50
- # ['threads', 7, 'information of currently-known threads',
51
- # 'This information includes whether the thread is the current thread ' \
52
- # '(+), it\'s suspended ($) or it\'s ignored (!), plus the thread ' \
53
- # 'number and the top stack item. If \'verbose\' is given then the ' \
54
- # 'entire stack frame is shown.'],
55
- ['variables', 1,
56
- 'Local and instance variables of the current stack frame']
22
+ Subcommands =
23
+ [
24
+ ['args', 1, 'Argument variables of current stack frame'],
25
+ ['breakpoints', 1, 'Status of user-settable breakpoints',
26
+ 'Without argument, list info about all breakpoints. With an integer ' \
27
+ 'argument, list info on that breakpoint.'],
28
+ ['catch', 3,
29
+ 'Exceptions that can be caught in the current stack frame'],
30
+ ['display', 2, 'Expressions to display when program stops'],
31
+ ['file', 4, 'Info about a particular file read in',
32
+ 'After the file name is supplied, you can list file attributes that ' \
33
+ 'you wish to see. Attributes include: "all", "basic", "breakpoint", ' \
34
+ '"lines", "mtime", "path" and "sha1".'],
35
+ ['files', 5, 'File names and timestamps of files read in'],
36
+ ['global_variables', 2, 'Global variables'],
37
+ ['instance_variables', 2,
38
+ 'Instance variables of the current stack frame'],
39
+ ['line', 2,
40
+ 'Line number and file name of current position in source file'],
41
+ ['locals', 2, 'Local variables of the current stack frame'],
42
+ ['program', 2, 'Execution status of the program'],
43
+ ['stack', 2, 'Backtrace of the stack'],
44
+ # ['thread', 6, 'List info about thread NUM',
45
+ # 'If no thread number is given, we list info for all threads. "terse"' \
46
+ # ' and "verbose" options are possible. If "terse", just give summary ' \
47
+ # 'thread name information. See "help info threads" for more detail ' \
48
+ # 'about this summary information. If "verbose" is appended to the end' \
49
+ # ' of the command, then the entire stack trace is given for each ' \
50
+ # 'thread.'],
51
+ # ['threads', 7, 'information of currently-known threads',
52
+ # 'This information includes whether the thread is the current thread ' \
53
+ # '(+), it\'s suspended ($) or it\'s ignored (!), plus the thread ' \
54
+ # 'number and the top stack item. If "verbose" is given then the ' \
55
+ # 'entire stack frame is shown.'],
56
+ ['variables', 1,
57
+ 'Local and instance variables of the current stack frame']
57
58
  ].map do |name, min, short_help, long_help|
58
59
  SubcmdStruct.new(name, min, short_help, long_help)
59
60
  end unless defined?(Subcommands)
60
61
 
61
- InfoFileSubcommands = [
62
- ['all', 1, 'All file information available - breakpoints, lines, mtime' \
63
- ', path and sha1'],
62
+ InfoFileSubcommands =
63
+ [
64
+ ['all', 1, 'All file information available - breakpoints, lines, ' \
65
+ 'mtime, path and sha1'],
64
66
  ['basic', 2, 'basic information - path, number of lines'],
65
67
  ['breakpoints', 2, 'Show trace line numbers',
66
68
  'These are the line number where a breakpoint can be set.'],
@@ -72,7 +74,8 @@ module Byebug
72
74
  SubcmdStruct.new(name, min, short_help, long_help)
73
75
  end unless defined?(InfoFileSubcommands)
74
76
 
75
- # InfoThreadSubcommands = [
77
+ # InfoThreadSubcommands =
78
+ # [
76
79
  # ['terse', 1, 'summary information'],
77
80
  # ['verbose', 1, 'summary information and stack frame info'],
78
81
  # ].map do |name, min, short_help, long_help|
@@ -84,17 +87,15 @@ module Byebug
84
87
  end
85
88
 
86
89
  def execute
87
- if !@match[1]
88
- print_subcommands
90
+ return print_subcmds(Subcommands) unless @match[1]
91
+
92
+ args = @match[1].split(/[ \t]+/)
93
+ param = args.shift
94
+ subcmd = find(Subcommands, param)
95
+ if subcmd
96
+ send("info_#{subcmd.name}", *args)
89
97
  else
90
- args = @match[1].split(/[ \t]+/)
91
- param = args.shift
92
- subcmd = find(Subcommands, param)
93
- if subcmd
94
- send("info_#{subcmd.name}", *args)
95
- else
96
- errmsg "Unknown info command #{param}\n"
97
- end
98
+ errmsg "Unknown info command #{param}\n"
98
99
  end
99
100
  end
100
101
 
@@ -167,24 +168,17 @@ module Byebug
167
168
  end
168
169
 
169
170
  def info_file(*args)
170
- unless args[0]
171
- info_files
172
- return
173
- end
171
+ return info_files unless args[0]
174
172
  file = args[0]
175
- param = args[1]
176
173
 
177
- param = 'basic' unless param
174
+ param = args[1] ? args[1] : 'basic'
175
+
178
176
  subcmd = find(InfoFileSubcommands, param)
179
- unless subcmd
180
- errmsg "Invalid parameter #{param}\n"
181
- return
182
- end
177
+ return errmsg "Invalid parameter #{param}\n" unless subcmd
183
178
 
184
179
  unless LineCache::cached?(file)
185
180
  unless LineCache::cached_script?(file)
186
- print "File #{file} is not cached\n"
187
- return
181
+ return print "File #{file} is not cached\n"
188
182
  end
189
183
  LineCache::cache(file, Command.settings[:reload_source_on_change])
190
184
  end
@@ -192,10 +186,9 @@ module Byebug
192
186
  print "File #{file}"
193
187
  path = LineCache.path(file)
194
188
  if %w(all basic path).member?(subcmd.name) and path != file
195
- print " - %s\n", path
196
- else
197
- print "\n"
189
+ print " - #{path}"
198
190
  end
191
+ print "\n"
199
192
 
200
193
  if %w(all basic lines).member?(subcmd.name)
201
194
  lines = LineCache.size(file)
@@ -214,6 +207,7 @@ module Byebug
214
207
  stat = LineCache.stat(file)
215
208
  print "\t%s\n", stat.mtime if stat
216
209
  end
210
+
217
211
  if %w(all sha1).member?(subcmd.name)
218
212
  print "\t%s\n", LineCache.sha1(file)
219
213
  end
@@ -304,14 +298,7 @@ module Byebug
304
298
  errmsg "info stack not available here.\n"
305
299
  return
306
300
  end
307
- (0...@state.context.stack_size).each do |idx|
308
- if idx == @state.frame_pos
309
- print "--> "
310
- else
311
- print " "
312
- end
313
- print_frame(idx)
314
- end
301
+ print_backtrace
315
302
  end
316
303
 
317
304
  # def info_thread_preamble(arg)
@@ -407,33 +394,25 @@ module Byebug
407
394
  end
408
395
 
409
396
  def help(args)
397
+ # specific subcommand help
410
398
  if args[1]
411
- s = args[1]
412
- subcmd = Subcommands.find do |try_subcmd|
413
- (s.size >= try_subcmd.min) and
414
- (try_subcmd.name[0..s.size-1] == s)
415
- end
416
- if subcmd
417
- str = subcmd.short_help + '.'
418
- if 'file' == subcmd.name and args[2]
419
- s = args[2]
420
- subsubcmd = InfoFileSubcommands.find do |try_subcmd|
421
- (s.size >= try_subcmd.min) and
422
- (try_subcmd.name[0..s.size-1] == s)
423
- end
424
- if subsubcmd
425
- str += "\n" + subsubcmd.short_help + '.'
426
- else
427
- str += "\nInvalid file attribute #{args[2]}."
428
- end
429
- else
430
- str += "\n" + subcmd.long_help if subcmd.long_help
431
- end
432
- return str
399
+ subcmd = find(Subcommands, args[1])
400
+ return "Invalid \"info\" subcommand \"#{args[1]}\"." unless subcmd
401
+
402
+ str = subcmd.short_help + '.'
403
+ if 'file' == subcmd.name and args[2]
404
+ subsubcmd = find(InfoFileSubcommands, args[2])
405
+ return str += "\nInvalid \"file\" attribute \"#{args[2]}\"." \
406
+ unless subsubcmd
407
+
408
+ str += "\n" + subsubcmd.short_help + '.'
433
409
  else
434
- return "Invalid 'info' subcommand '#{args[1]}'."
410
+ str += "\n" + subcmd.long_help if subcmd.long_help
435
411
  end
412
+ return str
436
413
  end
414
+
415
+ # general help
437
416
  s = %{
438
417
  Generic command for showing things about the program being debugged.
439
418
  --
@@ -10,6 +10,9 @@ module Byebug
10
10
  ListCommand.always_run = value
11
11
  end
12
12
 
13
+ # Set default value
14
+ Command.settings[:autolist] = 1
15
+
13
16
  def regexp
14
17
  /^\s* l(?:ist)? (?:\s*([-=])|\s+(.+))? $/x
15
18
  end
@@ -4,35 +4,37 @@ module Byebug
4
4
  class SetCommand < Command
5
5
  SubcmdStruct2=Struct.new(:name, :min, :is_bool, :short_help,
6
6
  :long_help) unless defined?(SubcmdStruct2)
7
- Subcommands = [
8
- ['annotate', 2, false, "Set annotation level",
9
- '0 == normal. ' \
10
- '2 == output annotated suitably for use by programs that control ' \
11
- 'byebug.'],
12
- ['args', 2, false,
13
- 'Set argument list to give program being debugged when it is started'],
14
- ['autoeval', 4, true, "Evaluate every unrecognized command"],
15
- ['autolist', 4, true, "Execute 'list' command on every breakpoint"],
16
- ['autoirb', 4, true, "Invoke IRB on every stop"],
17
- ['autoreload', 4, true, "Reload source code when changed"],
18
- ['basename', 1, true, "Report file basename only showing file names"],
19
- ['callstyle', 2, false, "Set how you want call parameters displayed"],
20
- ['byebugtesting', 8, false, "Used when testing byebug"],
21
- ['forcestep', 2, true,
22
- 'Make sure \'next/step\' commands always move to a new line'],
23
- ['fullpath', 2, true, "Display full file names in frames"],
24
- ['history', 2, false,
25
- 'Generic command for setting command history parameters',
26
- 'set history filename -- Set the filename in which to record the ' \
27
- 'command history. ' \
28
- 'set history save -- Set saving of the history record on exit. ' \
29
- 'set history size -- Set the size of the command history'],
30
- ['linetrace+', 10, true,
31
- 'Set line execution tracing to show different lines'],
32
- ['linetrace', 3, true, "Set line execution tracing"],
33
- ['listsize', 3, false, "Set number of source lines to list by default"],
34
- ['trace', 1, true, "Display stack trace when 'eval' raises exception"],
35
- ['width', 1, false, 'Number of characters per line for byebug\'s output']
7
+ Subcommands =
8
+ [
9
+ ['annotate', 2, false, 'Set annotation level',
10
+ '0 == normal. ' \
11
+ '2 == output annotated suitably for use by programs that control ' \
12
+ 'byebug.'],
13
+ ['args', 2, false,
14
+ 'Set argument list to give program being debugged when it is started'],
15
+ ['autoeval', 4, true, 'Evaluate every unrecognized command'],
16
+ ['autolist', 4, true, 'Execute "list" command on every breakpoint'],
17
+ ['autoirb', 4, true, 'Invoke IRB on every stop'],
18
+ ['autoreload', 4, true, 'Reload source code when changed'],
19
+ ['basename', 1, true, 'Report file basename only showing file names'],
20
+ ['callstyle', 2, false, 'Set how you want call parameters displayed'],
21
+ ['byebugtesting', 8, false, 'Used when testing byebug'],
22
+ ['forcestep', 2, true,
23
+ 'Make sure "next/step" commands always move to a new line'],
24
+ ['fullpath', 2, true, 'Display full file names in frames'],
25
+ ['history', 2, false,
26
+ 'Generic command for setting command history parameters',
27
+ 'set history filename -- Set the filename in which to record the ' \
28
+ 'command history. ' \
29
+ 'set history save -- Set saving of the history record on exit. ' \
30
+ 'set history size -- Set the size of the command history'],
31
+ ['linetrace+', 10, true,
32
+ 'Set line execution tracing to show different lines'],
33
+ ['linetrace', 3, true, 'Set line execution tracing'],
34
+ ['listsize', 3, false, 'Set number of source lines to list by default'],
35
+ ['trace', 1, true, 'Display stack trace when "eval" raises exception'],
36
+ ['width', 1, false,
37
+ 'Number of characters per line for byebug\'s output']
36
38
  ].map do |name, min, is_bool, short_help, long_help|
37
39
  SubcmdStruct2.new(name, min, is_bool, short_help, long_help)
38
40
  end unless defined?(Subcommands)
@@ -44,129 +46,119 @@ module Byebug
44
46
  end
45
47
 
46
48
  def execute
47
- if not @match[1]
48
- print_subcommands
49
+ # "Set" alone just prints subcommands
50
+ return print_subcmds(Subcommands) unless @match[1]
51
+
52
+ args = @match[1].split(/[ \t]+/)
53
+ try_subcmd = args.shift
54
+ try_subcmd.downcase!
55
+ if try_subcmd =~ /^no/i
56
+ set_on = false
57
+ try_subcmd = try_subcmd[2..-1]
49
58
  else
50
- args = @match[1].split(/[ \t]+/)
51
- subcmd = args.shift
52
- subcmd.downcase!
53
- if subcmd =~ /^no/i
54
- set_on = false
55
- subcmd = subcmd[2..-1]
59
+ set_on = true
60
+ end
61
+
62
+ subcmd = find(Subcommands, try_subcmd)
63
+
64
+ # Subcommand not found...
65
+ return print "Unknown set command \"#{try_subcmd}\"\n" unless subcmd
66
+
67
+ set_on = get_onoff(args[0]) if subcmd.is_bool and args.size > 0
68
+
69
+ case subcmd.name
70
+ when /^annotate$/
71
+ level = get_int(args[0], "Set annotate", 0, 3, 0)
72
+ if level
73
+ Byebug.annotate = level
56
74
  else
57
- set_on = true
75
+ return
76
+ end
77
+ if defined?(Byebug::RDEBUG_SCRIPT)
78
+ # byebug was called initially. 1st arg is script name.
79
+ Command.settings[:argv][1..-1] = args
80
+ else
81
+ # byebug wasn't called initially. 1st arg is not script name.
82
+ Command.settings[:argv] = args
83
+ end
84
+ when /^args$/
85
+ Command.settings[:argv][1..-1] = args
86
+ when /^autolist$/
87
+ Command.settings[:autolist] = (set_on ? 1 : 0)
88
+ when /^autoeval$/
89
+ Command.settings[:autoeval] = set_on
90
+ when /^basename$/
91
+ Command.settings[:basename] = set_on
92
+ when /^callstyle$/
93
+ if args[0]
94
+ arg = args[0].downcase.to_sym
95
+ case arg
96
+ when :short, :last, :tracked
97
+ Command.settings[:callstyle] = arg
98
+ else
99
+ print "Invalid call style #{arg}. Should be one of: " \
100
+ "'short', 'last' or 'tracked'.\n"
101
+ end
102
+ end
103
+ when /^trace$/
104
+ Command.settings[:stack_trace_on_error] = set_on
105
+ when /^fullpath$/
106
+ Command.settings[:full_path] = set_on
107
+ when /^autoreload$/
108
+ Command.settings[:reload_source_on_change] = set_on
109
+ when /^autoirb$/
110
+ Command.settings[:autoirb] = (set_on ? 1 : 0)
111
+ when /^byebugtesting$/
112
+ Command.settings[:byebugtesting] = set_on
113
+ if set_on
114
+ Command.settings[:basename] = true
58
115
  end
59
- for try_subcmd in Subcommands do
60
- if (subcmd.size >= try_subcmd.min) and
61
- (try_subcmd.name[0..subcmd.size-1] == subcmd)
62
- begin
63
- if try_subcmd.is_bool
64
- if args.size > 0
65
- set_on = get_onoff(args[0])
66
- end
67
- end
68
- case try_subcmd.name
69
- when /^annotate$/
70
- level = get_int(args[0], "Set annotate", 0, 3, 0)
71
- if level
72
- Byebug.annotate = level
73
- else
74
- return
75
- end
76
- if defined?(Byebug::RDEBUG_SCRIPT)
77
- # byebug was called initially. 1st arg is script name.
78
- Command.settings[:argv][1..-1] = args
79
- else
80
- # byebug wasn't called initially. 1st arg is not script name.
81
- Command.settings[:argv] = args
82
- end
83
- when /^args$/
84
- Command.settings[:argv][1..-1] = args
85
- when /^autolist$/
86
- Command.settings[:autolist] = (set_on ? 1 : 0)
87
- when /^autoeval$/
88
- Command.settings[:autoeval] = set_on
89
- when /^basename$/
90
- Command.settings[:basename] = set_on
91
- when /^callstyle$/
92
- if args[0]
93
- arg = args[0].downcase.to_sym
94
- case arg
95
- when :short, :last, :tracked
96
- Command.settings[:callstyle] = arg
97
- else
98
- print "Invalid call style #{arg}. Should be one of: " \
99
- "'short', 'last' or 'tracked'.\n"
100
- end
101
- end
102
- when /^trace$/
103
- Command.settings[:stack_trace_on_error] = set_on
104
- when /^fullpath$/
105
- Command.settings[:full_path] = set_on
106
- when /^autoreload$/
107
- Command.settings[:reload_source_on_change] = set_on
108
- when /^autoirb$/
109
- Command.settings[:autoirb] = (set_on ? 1 : 0)
110
- when /^byebugtesting$/
111
- Command.settings[:byebugtesting] = set_on
112
- if set_on
113
- Command.settings[:basename] = true
114
- end
115
- when /^forcestep$/
116
- self.class.settings[:force_stepping] = set_on
117
- when /^history$/
118
- if 2 == args.size
119
- interface = @state.interface
120
- case args[0]
121
- when /^save$/
122
- interface.history_save = get_onoff(args[1])
123
- when /^size$/
124
- interface.history_length =
125
- get_int(args[1], "Set history size")
126
- when /^filename$/
127
- interface.histfile =
128
- File.join(ENV["HOME"]||ENV["HOMEPATH"]||".", args[1])
129
- else
130
- print "Invalid history parameter #{args[0]}. Should be " \
131
- "'filename', 'save' or 'size'.\n"
132
- end
133
- else
134
- print "Need two parameters for 'set history'; got " \
135
- "#{args.size}.\n"
136
- return
137
- end
138
- when /^linetrace\+$/
139
- self.class.settings[:tracing_plus] = set_on
140
- when /^linetrace$/
141
- Command.settings[:tracing] = set_on
142
- when /^listsize$/
143
- listsize = get_int(args[0], "Set listsize", 1, nil, 10)
144
- if listsize
145
- self.class.settings[:listsize] = listsize
146
- else
147
- return
148
- end
149
- when /^width$/
150
- width = get_int(args[0], "Set width", 10, nil, 80)
151
- if width
152
- self.class.settings[:width] = width
153
- ENV['COLUMNS'] = width.to_s
154
- else
155
- return
156
- end
157
- else
158
- print "Unknown setting #{@match[1]}.\n"
159
- return
160
- end
161
- print "#{show_setting(try_subcmd.name)}\n"
162
- return
163
- rescue RuntimeError
164
- return
165
- end
116
+ when /^forcestep$/
117
+ self.class.settings[:force_stepping] = set_on
118
+ when /^history$/
119
+ if 2 == args.size
120
+ interface = @state.interface
121
+ case args[0]
122
+ when /^save$/
123
+ interface.history_save = get_onoff(args[1])
124
+ when /^size$/
125
+ interface.history_length =
126
+ get_int(args[1], "Set history size")
127
+ when /^filename$/
128
+ interface.histfile =
129
+ File.join(ENV["HOME"]||ENV["HOMEPATH"]||".", args[1])
130
+ else
131
+ print "Invalid history parameter #{args[0]}. Should be " \
132
+ "'filename', 'save' or 'size'.\n"
166
133
  end
134
+ else
135
+ print "Need two parameters for 'set history'; got " \
136
+ "#{args.size}.\n"
137
+ return
138
+ end
139
+ when /^linetrace\+$/
140
+ self.class.settings[:tracing_plus] = set_on
141
+ when /^linetrace$/
142
+ Command.settings[:tracing] = set_on
143
+ when /^listsize$/
144
+ listsize = get_int(args[0], "Set listsize", 1, nil, 10)
145
+ if listsize
146
+ self.class.settings[:listsize] = listsize
147
+ else
148
+ return
149
+ end
150
+ when /^width$/
151
+ width = get_int(args[0], "Set width", 10, nil, 80)
152
+ if width
153
+ self.class.settings[:width] = width
154
+ ENV['COLUMNS'] = width.to_s
155
+ else
156
+ return
167
157
  end
168
- print "Unknown set command #{subcmd}\n"
158
+ else
159
+ return print "Unknown setting #{@match[1]}.\n"
169
160
  end
161
+ return print "#{show_setting(subcmd.name)}\n"
170
162
  end
171
163
 
172
164
  class << self
@@ -175,20 +167,17 @@ module Byebug
175
167
  end
176
168
 
177
169
  def help(args)
170
+ # specific subcommand help
178
171
  if args[1]
179
- s = args[1]
180
- subcmd = Subcommands.find do |try_subcmd|
181
- (s.size >= try_subcmd.min) and
182
- (try_subcmd.name[0..s.size-1] == s)
183
- end
184
- if subcmd
185
- str = subcmd.short_help + '.'
186
- str += "\n" + subcmd.long_help if subcmd.long_help
187
- return str
188
- else
189
- return "Invalid 'set' subcommand '#{args[1]}'."
190
- end
172
+ subcmd = find(Subcommands, args[1])
173
+ return "Invalid \"set\" subcommand \"#{args[1]}\"." unless subcmd
174
+
175
+ str = subcmd.short_help + '.'
176
+ str += "\n" + subcmd.long_help if subcmd.long_help
177
+ return str
191
178
  end
179
+
180
+ # general help
192
181
  s = %{
193
182
  Modifies parts of byebug environment. Boolean values take
194
183
  on, off, 1 or 0.