Move command-line parsing into a single function.