Skip to content

Commit

Permalink
add example for commands in context
Browse files Browse the repository at this point in the history
  • Loading branch information
mpapis committed Oct 18, 2014
1 parent 2254e1d commit fc4c7a0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion README.md
Expand Up @@ -35,13 +35,21 @@ This is framework to build command strings based on current context.
```ruby
subject = CommandDesigner::Dsl.new([:first, nil, :last])

subject.filter(:last, {:server => "::2" }) {|cmd| "command #{cmd}" }
subject.filter(:first, {:target => "true"}) {|cmd| "env #{cmd}" }

subject.local_filter(Proc.new{|cmd| "cd /path && #{cmd}" }) do

subject.command("true") # => "cd /path && env true"

subject.command("false") # => "cd /path && false"

end

subject.context(:server => "::2") do |server2|

# the :last filter with "command" was applied on the end
server2.command("true") # => "command env false"
server2.command("false") # => "command false"

end
```

0 comments on commit fc4c7a0

Please sign in to comment.