Use the GNU GetOpt feature to control the workflow.