title: Extracting filenames from command line arguments with Ruby
body: <p>I'm trying to use <a href="http://www.ruby-doc.org/stdlib/libdoc/optparse/rdoc/classes/OptionParser.html" rel="nofollow noreferrer">optparse</a> to parse command line arguments. I would like my program to accept arguments like that:</p>
  
  <pre><code>$ ./myscript.rb [options] filename
  </code></pre>
  
  <p>I can easily manage the <code>[options]</code> part:</p>
  
  <pre><code>require 'optparse'
  
  options = { :verbose =&gt; false, :type =&gt; :html }
  
  opts = OptionParser.new do |opts|
    opts.on('-v', '--verbose') do
      options[:verbose] = true
    end
    opts.on('-t', '--type', [:html, :css]) do |type|
      options[:type] = type
    end
  end
  opts.parse!(ARGV)
  </code></pre>
  
  <p>But how do I get the <code>filename</code>?</p>
  
  <p>I could extract it manually from <code>ARGV</code>, but there has to be a better solution, just can't figure out how</p>