Rewrite option parsing using getopt_long.