diff --git a/bin/catchmail b/bin/catchmail index ae4f0cc..6055455 100755 --- a/bin/catchmail +++ b/bin/catchmail @@ -33,6 +33,10 @@ OptionParser.new do |parser| options[:from] = from end + parser.on('-x', '--no-exit', 'Can\'t exit from the application') do + options[:no_exit] = true + end + parser.on('-h', '--help', 'Display this help information') do puts parser exit! diff --git a/lib/mail_catcher.rb b/lib/mail_catcher.rb index b203bbc..4a02103 100644 --- a/lib/mail_catcher.rb +++ b/lib/mail_catcher.rb @@ -55,6 +55,7 @@ module MailCatcher extend self :daemon => !windows?, :growl => growlnotify?, :browse => false, + :no_exit => false, } def parse! arguments=ARGV, defaults=@defaults @@ -83,6 +84,10 @@ module MailCatcher extend self options[:http_port] = port end + parser.on("--no-exit", "Can't exit from the application'") do + options[:no_exit] = true + end + if mac? parser.on("--[no-]growl", "Growl to the local machine when a message arrives") do |growl| if growl and not growlnotify? @@ -128,6 +133,10 @@ module MailCatcher extend self puts "Starting MailCatcher" + define_method :no_exit do + options[:no_exit] + end + Thin::Logging.silent = true # One EventMachine loop... diff --git a/lib/mail_catcher/web.rb b/lib/mail_catcher/web.rb index 496f6a9..85d2b60 100644 --- a/lib/mail_catcher/web.rb +++ b/lib/mail_catcher/web.rb @@ -18,8 +18,10 @@ class MailCatcher::Web < Sinatra::Base end delete '/' do - MailCatcher.quit! - status 204 + unless MailCatcher.no_exit + MailCatcher.quit! + status 204 + end end get '/messages' do diff --git a/views/index.haml b/views/index.haml index 8880f20..b057d57 100644 --- a/views/index.haml +++ b/views/index.haml @@ -21,8 +21,9 @@ %input{:type => 'search', :name => 'search', :placeholder => 'Search messages...', :incremental => true} %li.clear %a{:href => '#', :title => 'Clear all messages'} Clear - %li.quit - %a{:href => '#', :title => 'Quit MailCatcher'} Quit + - unless MailCatcher.no_exit + %li.quit + %a{:href => '#', :title => 'Quit MailCatcher'} Quit %nav#messages %table %thead