add .gitignore
migrate to getopt lib and structure the code

migrate to getopt lib and structure the code. It works.