mirror of
https://github.com/moparisthebest/mailcatcher
synced 2024-12-22 07:18:53 -05:00
Add option to disable the exit button and action
This commit is contained in:
parent
e19a2096b0
commit
6ce4dda354
@ -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!
|
||||
|
@ -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...
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user