title: Parse command line arguments in a Ruby script
body: <p>I want to call a Ruby script from the command line, and pass in parameters that are key/value pairs.</p>
  
  <p>Command line call:</p>
  
  <pre><code>$ ruby my_script.rb --first_name=donald --last_name=knuth
  </code></pre>
  
  <p>my_script.rb:</p>
  
  <pre><code>puts args.first_name + args.last_name
  </code></pre>
  
  <p>What is the standard Ruby way to do this? In other languages I usually have to use an option parser. In Ruby I saw we have <code>ARGF.read</code>, but that does not seem to work key/value pairs like in this example.</p>
  
  <p><a href="http://ruby-doc.org/stdlib-2.1.1/libdoc/optparse/rdoc/OptionParser.html#method-i-getopts" rel="noreferrer">OptionParser</a> looks promising, but I can't tell if it actually supports this case.</p>