Borrowed some code from command-line-arguments.