Improve command line parsing.
Merge pull request #2313 from glassez/cmdline

Improve command line parsing.