Permalink
Browse files

Rewrote Readme

  • Loading branch information...
1 parent 0eef0b7 commit 912ff032fe535e8724da3935cc6e91f077d9662e @hawx hawx committed Mar 9, 2012
Showing with 32 additions and 11 deletions.
  1. +32 −11 Readme.md
View
43 Readme.md
@@ -22,25 +22,46 @@ And then add a basic setup to your Guardfile:
## Usage
-If you can do something in your shell, it is probably very easy to setup with
-guard-shell. It can take an option, `:all_on_start` which will, if set to true,
-run all tasks on start.
+If you can do something in your shell, or in ruby, you can do it when a file changes
+with guard-shell. It simply executes the block passed to watch if a change is
+detected, and if anything is returned from the block it will be printed. For example
-There is also a shortcut method, `#n(msg, title='', image=nil)`, which can
-be used to display a notification within your watch blocks. The image can be either
-`:success`, `:pending` or `:failed`. See the examples for usage.
+``` ruby
+guard :shell do
+ watch /.*/ do |m|
+ m[0] + " has changed."
+ end
+end
+```
-### Examples
+will simply print a message telling you a file has been changed when it is changed.
+This admittedly isn't a very useful example, but you hopefully get the idea. To run
+everything on start pass `:all_on_start` to `#guard`,
+
+``` ruby
+guard :shell, :all_on_start => true do
+ # ...
+end
+```
-#### Printing the Name of the File You Changed
+There is also a shortcut for easily creating notifications,
``` ruby
guard :shell do
- # if the block returns something, it will be printed with `puts`
- watch(/(.*)/) {|m| m[0] + " was just changed" }
+ watch /.*/ do |m|
+ n m[0], 'File Changed'
+ end
end
```
+`#n` takes up to three arguments; the first is the body of the message, here the path
+of the changed file; the second is the title for the notification; and the third is
+the image to use. There are three (four counting `nil` the default) different images
+that can be specified `:success`, `:pending` and `:failed`.
+
+
+### Examples
+
#### Saying the Name of the File You Changed and Displaying a Notification
``` ruby
@@ -68,7 +89,7 @@ guard :shell, :all_on_start => true do
end
```
-#### Check Syntax of Ruby File
+#### Check Syntax of a Ruby File
``` ruby
guard :shell do

0 comments on commit 912ff03

Please sign in to comment.