Use getopt instead of manual strcmp checks