int main(int argc, char **argv)
{
bool debug = false;
+ string re_str;
GetOpt getopt;
getopt.add_option('d', "debug", debug, GetOpt::NO_ARG);
+ getopt.add_argument("regex", re_str, GetOpt::REQUIRED_ARG);
getopt(argc, argv);
- const vector<string> &args = getopt.get_args();
-
- if(args.empty())
- {
- cerr<<"Usage: "<<argv[0]<<" <regex>\n";
- return 1;
- }
-
- Regex regex(args[0]);
+ Regex regex(re_str);
if(debug)
- cout<<regex.disassemble();
+ cout << regex.disassemble();
string line;
while(getline(cin, line))
{
if(RegMatch match = regex.match(line))
- cout<<line<<'\n';
+ cout << line << '\n';
}
return 0;