Class: Readapt::Shell

Inherits:
Thor
  • Object
show all
Defined in:
lib/readapt/shell.rb

Instance Method Summary collapse

Instance Method Details

#socketObject



19
20
21
22
23
24
25
26
27
# File 'lib/readapt/shell.rb', line 19

def socket
  machine = Backport::Machine.new
  machine.run do
    prepare_machine machine
    server = Backport::Server::Tcpip.new(host: options[:host], port: options[:port], adapter: Readapt::Server)
    machine.prepare server
    STDERR.puts "Readapt Debugger #{Readapt::VERSION} is listening HOST=#{options[:host]} PORT=#{options[:port]} PID=#{Process.pid}"
  end
end

#stdioObject



31
32
33
34
35
36
37
38
# File 'lib/readapt/shell.rb', line 31

def stdio
  machine = Backport::Machine.new
  machine.run do
    prepare_machine machine
    server = Backport::Server::Stdio.new(adapter: Readapt::Server)
    machine.prepare server
  end
end

#target(procid = nil) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/readapt/shell.rb', line 41

def target procid = nil
  STDIN.binmode
  STDOUT.binmode
  STDERR.binmode
  STDOUT.sync = true
  STDERR.sync = true
  Readapt::Adapter.procid = procid
  machine = Backport::Machine.new
  Signal.trap("INT") do
    graceful_shutdown machine
  end
  Signal.trap("TERM") do
    graceful_shutdown machine
  end
  machine.run do
    debugger = Readapt::Debugger.new
    Readapt::Adapter.host debugger
    machine.prepare Backport::Server::Stdio.new(input: STDIN, output: STDERR, adapter: Readapt::Adapter)
  end
end

#versionObject



12
13
14
# File 'lib/readapt/shell.rb', line 12

def version
  puts Readapt::VERSION
end