mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 15:18:01 +00:00
20 lines
428 B
Markdown
20 lines
428 B
Markdown
# 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)
|