Permalink
Browse files

Add quit action to the interactor

  • Loading branch information...
1 parent 3254e13 commit c8f61427b4ed45779745b57580061dee3d2cd99b @Maher4Ever Maher4Ever committed Dec 20, 2011
Showing with 20 additions and 12 deletions.
  1. +13 −12 lib/guard/interactor.rb
  2. +7 −0 spec/guard/interactor_spec.rb
View
@@ -10,12 +10,13 @@ module Guard
#
# Currently the following actions are implemented:
#
- # - h, help => Show help
- # - e, exit => Exit Guard
- # - r, reload => Reload Guard
- # - p, pause => Toggle file modification listener
- # - n, notification => Toggle notifications
- # - <enter> => Run all
+ # - h, help => Show help
+ # - e, exit,
+ # q. quit => Exit Guard
+ # - r, reload => Reload Guard
+ # - p, pause => Toggle file modification listener
+ # - n, notification => Toggle notifications
+ # - <enter> => Run all
#
# It's also possible to scope `reload` and `run all` actions to only a specified group or a guard.
#
@@ -32,7 +33,7 @@ class Interactor
HELP_ENTRIES = %w[help h]
RELOAD_ENTRIES = %w[reload r]
- STOP_ENTRIES = %w[exit e]
+ STOP_ENTRIES = %w[exit e quit q]
PAUSE_ENTRIES = %w[pause p]
NOTIFICATION_ENTRIES = %w[notification n]
@@ -44,7 +45,7 @@ def initialize
unless defined?(RbReadline) || defined?(JRUBY_VERSION)
::Guard::UI.info 'Please add rb-readline for proper Readline support.'
end
-
+
Readline.completion_proc = proc { |word| auto_complete(word) }
begin
@@ -159,10 +160,10 @@ def toggle_notification
#
def help
puts ''
- puts 'e, exit Exit Guard'
- puts 'p, pause Toggle file modification listener'
- puts 'r, reload Reload Guard'
- puts 'n, notification Toggle notifications'
+ puts '[e]xit, [q]uit Exit Guard'
+ puts '[p]ause Toggle file modification listener'
+ puts '[r]eload Reload Guard'
+ puts '[n]otification Toggle notifications'
puts '<enter> Run all Guards'
puts ''
puts 'You can scope the reload action to a specific guard or group:'
@@ -219,6 +219,13 @@ class Guard::FooBar < Guard::Guard;
subject.extract_scopes_and_action('x x').should eql([{ }, nil])
end
+ describe 'extracting actions' do
+ it "returns :stop action for exit or quit entrie and for their shortcuts" do
+ %w{exit e quit q}.each do |e|
+ subject.extract_scopes_and_action(e).should eql([{ }, :stop])
+ end
+ end
+ end
end
end

0 comments on commit c8f6142

Please sign in to comment.