added a main, parses opts from command line