Class: Byebug::Runner

Inherits:
Object
  • Object
show all
Includes:
ParseFunctions
Defined in:
lib/byebug/runner.rb

Overview

Responsible for starting the debugger when started from the command line.

Defined Under Namespace

Classes: InvalidScript, NoScript, NonExistentScript

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ParseFunctions

#get_int, #parse_steps, #syntax_valid?, #without_stderr

Constructor Details

#initialize(stop = true, quit = true) ⇒ Runner

starting the program.

finishing the program.

Parameters:

  • stop (Boolean) (defaults to: true)

    Whether the runner should stop right before

  • quit (Boolean) (defaults to: true)

    Whether the runner should quit right after



38
39
40
# File 'lib/byebug/runner.rb', line 38

def initialize(stop = true, quit = true)
  @stop, @quit = stop, quit
end

Instance Attribute Details

#helpObject

Special working modes that don’t actually start the debugger.



29
30
31
# File 'lib/byebug/runner.rb', line 29

def help
  @help
end

#remoteObject

Special working modes that don’t actually start the debugger.



29
30
31
# File 'lib/byebug/runner.rb', line 29

def remote
  @remote
end

#versionObject

Special working modes that don’t actually start the debugger.



29
30
31
# File 'lib/byebug/runner.rb', line 29

def version
  @version
end

Instance Method Details

Usage banner.



45
46
47
48
49
50
51
52
53
# File 'lib/byebug/runner.rb', line 45

def banner
  <<-EOB.gsub(/^ {8}/, '')

      byebug #{Byebug::VERSION}

      Usage: byebug [options] <script.rb> -- <script.rb parameters>

  EOB
end

#runObject

Starts byebug to debug a program



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/byebug/runner.rb', line 58

def run
  prepare_options.order!($ARGV)

  if version
    Byebug.puts("\n  Running byebug #{version}\n")
    return
  end

  if help
    Byebug.puts("#{help}\n")
    return
  end

  if remote
    Byebug.start_client(*remote)
    return
  end

  setup_cmd_line_args

  loop do
    debug_program

    break if @quit

    processor = Byebug::ControlCommandProcessor.new
    processor.process_commands
  end
end