Sha256: 87e8623ea2bcab6063a038b5c81b517c104ad9f0956c4e90b945ce42c9356811
Contents?: true
Size: 1.79 KB
Versions: 2
Compression:
Stored size: 1.79 KB
Contents
#!/usr/bin/env ruby require 'optparse' require 'byebug/dap' USAGE = <<-EOS Usage: byebug-dap [options] <--stdio|--unix dap.socket|--listen 12345> <program> EOS def next_arg arg = ARGV.pop return arg if arg STDERR.puts USAGE exit! end options = {} OptionParser.new do |opts| opts.banner = USAGE opts.on("--stdio", "Listen on STDIN and STDOUT") { |v| options[:stdio] = v } opts.on("--listen PORT", "Listen on a TCP port") { |v| options[:listen] = v } opts.on("--unix SOCKET", "Listen on a unix socket") { |v| options[:unix] = v } opts.on("-w", "--[no-]wait", "Wait for attach or launch command before running program") { |v| options[:wait] = v } opts.on("-f", "--[no-]force", "When listening on a unix socket, delete the socket if it exists") { |v| options[:force] = v } opts.on("--debug-protocol", "Debug DAP") { |v| Byebug::DAP::Debug.protocol = true if v } opts.on("--debug-evaluate", "Debug variable evaluation") { |v| Byebug::DAP::Debug.evaluate = true if v } end.parse! program = next_arg if program == '-' program = next_arg options[:stdio] = true end if options[:stdio] host, port = :stdio, nil elsif options[:listen] host, port = options[:listen].split(':') host, port = 'localhost', host unless port elsif options[:unix] host, port = :unix, options[:unix] if File.exist?(port) if options[:force] File.delete(port) else puts "#{port} already exists" exit! end end else STDERR.puts USAGE, "One of --stdio, --listen, or --unix is required" exit! end begin STDERR.puts "Starting DAP" STDERR.flush if options[:wait] Byebug.start_dap(host, port) { require File.realpath(program) } else Byebug.start_dap(host, port) require File.realpath(program) end ensure File.delete(port) if File.exist?(port) if host == :unix end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
byebug-dap-0.1.1 | bin/byebug-dap |
byebug-dap-0.1.0 | bin/byebug-dap |