use getopt and support some grep-like options