Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add command line options
  • Loading branch information
FooBarWidget committed Apr 17, 2010
1 parent 0697131 commit 7b4e482
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
39 changes: 38 additions & 1 deletion bin/crash-watch
@@ -1,8 +1,45 @@
#!/usr/bin/env ruby
require 'crash_watch/gdb_controller'
require 'optparse'

options = {}
parser = OptionParser.new do |opts|
opts.banner = "Usage: crash-watch [options] PID"
opts.separator ""

opts.separator "Options:"
opts.on("-d", "--debug", "Show GDB commands that crash-watch sends.") do
options[:debug] = true
end
opts.on("-v", "--version", "Show version number.") do
options[:version] = true
end
opts.on("-h", "--help", "Show this help message.") do
options[:help] = true
end
end
begin
parser.parse!
rescue OptionParser::ParseError => e
puts e
puts
puts "Please see '--help' for valid options."
exit 1
end

if options[:help]
puts parser
exit
elsif options[:version]
require 'crash_watch/version'
puts "crash-watch version #{CrashWatch::VERSION_STRING}"
exit
end

require 'crash_watch/gdb_controller'
gdb = CrashWatch::GdbController.new
begin
gdb.debug = options[:debug]

# Ruby sometimes uses SIGVTARLM for thread scheduling.
gdb.execute("handle SIGVTALRM noprint pass")

Expand Down
4 changes: 3 additions & 1 deletion crash-watch.gemspec
@@ -1,6 +1,8 @@
require File.expand_path('lib/crash_watch/version', File.dirname(__FILE__))

Gem::Specification.new do |s|
s.name = "crash-watch"
s.version = "1.0.0"
s.version = CrashWatch::VERSION_STRING
s.authors = ["Hongli Lai"]
s.date = "2010-04-16"
s.description = "Monitor processes and display useful information when they crash."
Expand Down
3 changes: 3 additions & 0 deletions lib/crash_watch/version.rb
@@ -0,0 +1,3 @@
module CrashWatch
VERSION_STRING = '1.0.0'
end

0 comments on commit 7b4e482

Please sign in to comment.