title: How can I pass named arguments to a Rake task?
body: <p>Is there a way to pass named arguments to a Rake task without using environment variables?</p>
  
  <p>I am aware that Rake tasks can accept arguments in two formats:</p>
  
  <p><strong>Environment Variables</strong></p>
  
  <pre><code>$ rake my_task foo=bar
  </code></pre>
  
  <p>This creates an environment variable with the name <code>foo</code> and the value <code>bar</code> that can be accessed in the Rake task <code>my_task</code> by <code>ENV['foo']</code>.</p>
  
  <p><strong>Rake Task Arguments</strong></p>
  
  <pre><code>$ rake my_task['foo','bar']
  </code></pre>
  
  <p>This passes the values <code>foo</code> and <code>bar</code> to the first two task arguments (if they are defined). If <code>my_task</code> were defined as:</p>
  
  <pre><code>task :my_task, :argument_1, :argument_2
  </code></pre>
  
  <p>then <code>argument_1</code> would have the value <code>foo</code> and <code>argument_2</code> would have the value <code>bar</code>.</p>