lib/byebug/commands/enable.rb in byebug-1.3.0 vs lib/byebug/commands/enable.rb in byebug-1.3.1

- old
+ new

@@ -62,22 +62,20 @@ def regexp /^\s* en(?:able)? (?:\s+(.*))?$/ix end def execute - if not @match[1] - errmsg "\"enable\" must be followed by \"display\", \"breakpoints\" " \ - "or breakpoint numbers.\n" + return errmsg "\"enable\" must be followed by \"display\", " \ + "\"breakpoints\" or breakpoint numbers.\n" unless @match[1] + + args = @match[1].split(/[ \t]+/) + param = args.shift + subcmd = find(Subcommands, param) + if subcmd + send("enable_#{subcmd.name}", args) else - args = @match[1].split(/[ \t]+/) - param = args.shift - subcmd = find(Subcommands, param) - if subcmd - send("enable_#{subcmd.name}", args) - else - send('enable_breakpoints', args.unshift(param)) - end + send('enable_breakpoints', args.unshift(param)) end end def enable_breakpoints(args) enable_disable_breakpoints('Enable', args) @@ -85,21 +83,10 @@ def enable_display(args) enable_disable_display('Enable', args) end - def help - if args[1] - subcmd = find(Subcommands, args[1]) - return "Invalid \"enable\" subcommand \"#{args[1]}\"." unless subcmd - str = subcmd.short_help + '.' - str += '\n' + subcmd.long_help if subcmd.long_help - return str - end - EnableCommand.description + format_subcmds(Subcommands) - end - class << self def names %w(enable) end @@ -129,42 +116,28 @@ def regexp /^\s* dis(?:able)? (?:\s+(.*))?$/ix end def execute - if not @match[1] - errmsg "\"disable\" must be followed by \"display\", \"breakpoints\" " \ - "or breakpoint numbers.\n" + return errmsg "\"disable\" must be followed by \"display\", " \ + "\"breakpoints\" or breakpoint numbers.\n" unless @match[1] + + args = @match[1].split(/[ \t]+/) + param = args.shift + subcmd = find(Subcommands, param) + if subcmd + send("disable_#{subcmd.name}", args) else - args = @match[1].split(/[ \t]+/) - param = args.shift - subcmd = find(Subcommands, param) - if subcmd - send("disable_#{subcmd.name}", args) - else - send('disable_breakpoints', args.unshift(param)) - end + send('disable_breakpoints', args.unshift(param)) end end def disable_breakpoints(args) enable_disable_breakpoints('Disable', args) end def disable_display(args) enable_disable_display('Disable', args) - end - - def help(args) - if args[1] - subcmd = find(Subcommands, args[1]) - return "Invalid \"disable\" subcommand \"#{args[1]}\"." unless subcmd - - str = subcmd.short_help + '.' - str += '\n' + subcmd.long_help if subcmd.long_help - return str - end - DisableCommand.description + format_subcmds(Subcommads) end class << self def names %w(disable)