Add option to disable the exit button and action

This commit is contained in:
Julien Kirch 2013-05-13 13:27:06 +02:00
parent e19a2096b0
commit 6ce4dda354
4 changed files with 20 additions and 4 deletions

View File

@ -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!

View File

@ -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...

View File

@ -18,9 +18,11 @@ class MailCatcher::Web < Sinatra::Base
end
delete '/' do
unless MailCatcher.no_exit
MailCatcher.quit!
status 204
end
end
get '/messages' do
if request.websocket?

View File

@ -21,6 +21,7 @@
%input{:type => 'search', :name => 'search', :placeholder => 'Search messages...', :incremental => true}
%li.clear
%a{:href => '#', :title => 'Clear all messages'} Clear
- unless MailCatcher.no_exit
%li.quit
%a{:href => '#', :title => 'Quit MailCatcher'} Quit
%nav#messages