title: What is the design pattern for processing command line arguments
body: <p>If you are writing a program that is executable from the command line, you often want to offer the user several options or flags, along with possibly more than one argument. I have stumbled my way through this many times, but is there some sort of design pattern for looping through args and calling the appropriate handler functions?</p>
  
  <p>Consider:</p>
  
  <pre><code>myprogram -f filename -d directory -r regex
  </code></pre>
  
  <p>How do you organize the handler functions after you retrieve the arguments using whatever built-ins for your language? (language-specific answers welcomed, if that helps you articulate an answer)</p>