Class: Debugger::QuitCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/ruby-debug/commands/quit.rb

Overview

Implements debugger “quit” command

Constant Summary

Constants inherited from Command

Command::DEF_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

commands, #find, inherited, #initialize, load_commands, #match, method_missing, options, register_setting_get, register_setting_set, register_setting_var, settings, settings_map

Constructor Details

This class inherits a constructor from Debugger::Command

Class Method Details

.help(cmd) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/ruby-debug/commands/quit.rb', line 38

def help(cmd)
  %{
    q[uit] [!|unconditionally]\texit from debugger.
    exit[!]\talias to quit

    Normally we prompt before exiting. However if the parameter
    "unconditionally" or is given or suffixed with !, we stop
    without asking further questions.
   }
end

.help_commandObject



34
35
36
# File 'lib/ruby-debug/commands/quit.rb', line 34

def help_command
  %w[quit exit]
end

Instance Method Details

#executeObject



15
16
17
18
19
20
# File 'lib/ruby-debug/commands/quit.rb', line 15

def execute
  if really_leave_me?
    @state.interface.finalize
    exit! # exit -> exit!: No graceful way to stop threads...
  end
end

#really_leave_me?Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
30
31
# File 'lib/ruby-debug/commands/quit.rb', line 22

def really_leave_me?
  #let's only make it completely needy if the user misses the attention
  return true unless ENV['needy_debugger']

  @match[1] or
    confirm("Really quit? (y/n) ") and
    confirm("You know I do love you? (y/n) ") and
    confirm("It's been great working together hasn't it? (y/n) ") and
    confirm("Goodbye? (y/n) ")
end

#regexpObject



7
8
9
10
11
12
13
# File 'lib/ruby-debug/commands/quit.rb', line 7

def regexp
  / ^\s*
     (?:q(?:uit)?|exit) \s*
     (!|\s+unconditionally)? \s*
     $
  /ix
end