Use gnu getopt

Use gnu getopt to parse command line arguments.