title: How to parse an argument without a name with Ruby's optparse
body: <p>I need to parse a command line like</p>
  
  <pre><code>  script.rb &lt;mandatory filename&gt; [options]
  </code></pre>
  
  <p>with <a href="http://ruby-doc.org/stdlib/libdoc/optparse/rdoc/index.html" rel="noreferrer">optparse</a>.</p>
  
  <p>Sure I can write some custom code to handle the filename, then pass <code>ARGV</code> to optparse, but maybe there's a simpler way to do it?</p>
  
  <p>EDIT: there's another hacky way to parse such a command line, and that is pass <code>['--mandatory-filename'] + ARGV</code> to optparse, then handle the <code>--mandatory-filename</code> option.</p>