Sha256: dc14fbaacb8ff5381a3d0bc3a083cc48bbea474e4b288abcd65d5cf2e8bc7fef
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
require 'optparse' require_relative '../gdbdump' class Gdbdump class CLI def parse_options(argv = ARGV) op = OptionParser.new self.class.module_eval do define_method(:usage) do |msg = nil| puts op.to_s puts "error: #{msg}" if msg exit 1 end end opts = { debug: false, gdbinit: nil, gdb: nil, ruby: nil, } op.on('-d', '--[no-]debug', "print debug log (default: #{opts[:debug]})") {|v| opts[:debug] = v } op.on('-x', '--gdbinit FILE', "path to ruby trunk's .gdbinit (default: some of ruby trunk's .gdbinit is pre-bundle in this gem)") {|v| opts[:gdbinit] = v } op.on('--gdb PATH', "path to gdb command (default: gdb)") {|v| opts[:gdb] = v } op.on('--ruby PATH', "path to ruby which the attached process uses (default: get from /proc/[PID]/exe)") {|v| opts[:ruby] = v } op.banner += ' pid' begin args = op.parse(argv) rescue OptionParser::InvalidOption => e usage e.message end if args.size == 1 @pid = args.first else usage 'number of arguments must be 1' end @opts = opts end def run parse_options GDB.new(pid: @pid, **(@opts)).print_backtrace end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gdbdump-0.9.2 | lib/gdbdump/cli.rb |
gdbdump-0.9.1 | lib/gdbdump/cli.rb |