mirror of
https://github.com/moparisthebest/mailcatcher
synced 2024-12-22 15:28:52 -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
|
options[:from] = from
|
||||||
end
|
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
|
parser.on('-h', '--help', 'Display this help information') do
|
||||||
puts parser
|
puts parser
|
||||||
exit!
|
exit!
|
||||||
|
@ -55,6 +55,7 @@ module MailCatcher extend self
|
|||||||
:daemon => !windows?,
|
:daemon => !windows?,
|
||||||
:growl => growlnotify?,
|
:growl => growlnotify?,
|
||||||
:browse => false,
|
:browse => false,
|
||||||
|
:no_exit => false,
|
||||||
}
|
}
|
||||||
|
|
||||||
def parse! arguments=ARGV, defaults=@defaults
|
def parse! arguments=ARGV, defaults=@defaults
|
||||||
@ -83,6 +84,10 @@ module MailCatcher extend self
|
|||||||
options[:http_port] = port
|
options[:http_port] = port
|
||||||
end
|
end
|
||||||
|
|
||||||
|
parser.on("--no-exit", "Can't exit from the application'") do
|
||||||
|
options[:no_exit] = true
|
||||||
|
end
|
||||||
|
|
||||||
if mac?
|
if mac?
|
||||||
parser.on("--[no-]growl", "Growl to the local machine when a message arrives") do |growl|
|
parser.on("--[no-]growl", "Growl to the local machine when a message arrives") do |growl|
|
||||||
if growl and not growlnotify?
|
if growl and not growlnotify?
|
||||||
@ -128,6 +133,10 @@ module MailCatcher extend self
|
|||||||
|
|
||||||
puts "Starting MailCatcher"
|
puts "Starting MailCatcher"
|
||||||
|
|
||||||
|
define_method :no_exit do
|
||||||
|
options[:no_exit]
|
||||||
|
end
|
||||||
|
|
||||||
Thin::Logging.silent = true
|
Thin::Logging.silent = true
|
||||||
|
|
||||||
# One EventMachine loop...
|
# One EventMachine loop...
|
||||||
|
@ -18,9 +18,11 @@ class MailCatcher::Web < Sinatra::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
delete '/' do
|
delete '/' do
|
||||||
|
unless MailCatcher.no_exit
|
||||||
MailCatcher.quit!
|
MailCatcher.quit!
|
||||||
status 204
|
status 204
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
get '/messages' do
|
get '/messages' do
|
||||||
if request.websocket?
|
if request.websocket?
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
%input{:type => 'search', :name => 'search', :placeholder => 'Search messages...', :incremental => true}
|
%input{:type => 'search', :name => 'search', :placeholder => 'Search messages...', :incremental => true}
|
||||||
%li.clear
|
%li.clear
|
||||||
%a{:href => '#', :title => 'Clear all messages'} Clear
|
%a{:href => '#', :title => 'Clear all messages'} Clear
|
||||||
|
- unless MailCatcher.no_exit
|
||||||
%li.quit
|
%li.quit
|
||||||
%a{:href => '#', :title => 'Quit MailCatcher'} Quit
|
%a{:href => '#', :title => 'Quit MailCatcher'} Quit
|
||||||
%nav#messages
|
%nav#messages
|
||||||
|
Loading…
Reference in New Issue
Block a user