1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 23:28:02 +00:00

Add Passing Arguments To A Rake Task as a ruby til.

This commit is contained in:
jbranchaud
2015-08-04 19:03:17 -05:00
parent ea239b7827
commit 647205e995
2 changed files with 20 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
# Passing Arguments To A Rake Task
You can create a rake task that takes arguments by including an array of
named arguments in the task declaration.
```ruby
task :greeting, [:name] do |task, args|
puts "Hello, #{args.name}!"
end
```
You can then pass an argument to that task when invoking it.
```bash
$ rake greeting[World]
Hello, World!
```
[source](http://davidlesches.com/blog/passing-arguments-to-a-rails-rake-task)