Use getopt() to rewrite main.cc