Reduce code duplication in argument parsing (based on ros-infrastructure/ros_buildfarm#11)